Browse Source

refactor(新手引导): 使用服务状态替代本地存储检查

将新手引导完成状态的检查从本地存储改为直接使用NoviceGuideService中的状态变量,提高代码一致性和可维护性
weicu
lxm 1 year ago
parent
commit
1a29a0eab9
  1. 2
      lib/data/services/novice_guide_service.dart
  2. 4
      lib/modules/home/controllers/home_controller.dart

2
lib/data/services/novice_guide_service.dart

@ -14,7 +14,7 @@ class NoviceGuideService extends GetxService {
final BleService _bleService = BleService(); final BleService _bleService = BleService();
StreamSubscription<dynamic>? _statusSubscription; StreamSubscription<dynamic>? _statusSubscription;
bool isHomeGuide = false; bool isHomeGuide = false; //false代表未完成新手引导,true代表已经完成
bool isAIGuide = false; bool isAIGuide = false;
RxBool isWakeup = false.obs; RxBool isWakeup = false.obs;

4
lib/modules/home/controllers/home_controller.dart

@ -177,7 +177,7 @@ class HomeController extends GetxController {
bool wasConnected = _isFullyConnected.value; bool wasConnected = _isFullyConnected.value;
bool isNowConnected = hasClassicBluetooth && hasBleConnection; bool isNowConnected = hasClassicBluetooth && hasBleConnection;
bool isGuideCompleted = _storage.read('home_guide') ?? false; //bool isGuideCompleted = _storage.read('home_guide') ?? false;
if (isNowConnected && currentDevice == null) { if (isNowConnected && currentDevice == null) {
isNowConnected = false; isNowConnected = false;
@ -197,7 +197,7 @@ class HomeController extends GetxController {
// 移除了连接成功后的电池信息刷新 // 移除了连接成功后的电池信息刷新
// 连接成功后检查OTA升级 // 连接成功后检查OTA升级
if (isGuideCompleted) { if (noviceGuideService.isHomeGuide) {
Future.delayed(const Duration(seconds: 2), () { Future.delayed(const Duration(seconds: 2), () {
_checkOtaUpgrade(); _checkOtaUpgrade();
}); });

Loading…
Cancel
Save