fix(mobile): always check for updates and add debug logs

- Remove condition that only checked updates when wallet was created
- Add debug logging to version checker and self hosted updater
- Updates should now prompt on every app launch

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-09 07:52:00 -08:00
parent 2ed1658c16
commit 53320df220
3 changed files with 14 additions and 10 deletions

View File

@ -19,13 +19,16 @@ class SelfHostedUpdater {
///
Future<void> checkAndPromptUpdate(BuildContext context) async {
debugPrint('[SelfHostedUpdater] 开始检查更新...');
final versionInfo = await versionChecker.checkForUpdate();
if (versionInfo == null) {
debugPrint('Already latest version');
debugPrint('[SelfHostedUpdater] 已是最新版本,无需更新');
return;
}
debugPrint('[SelfHostedUpdater] 发现新版本: ${versionInfo.version}, versionCode: ${versionInfo.versionCode}');
if (!context.mounted) return;
//

View File

@ -25,6 +25,8 @@ class VersionChecker {
Future<VersionInfo?> fetchLatestVersion() async {
try {
final currentInfo = await getCurrentVersion();
debugPrint('[VersionChecker] 当前版本: ${currentInfo.version}, buildNumber: ${currentInfo.buildNumber}');
debugPrint('[VersionChecker] API URL: $apiBaseUrl/api/app/version/check');
final response = await _dio.get(
'/api/app/version/check',
@ -35,17 +37,22 @@ class VersionChecker {
},
);
debugPrint('[VersionChecker] 响应状态: ${response.statusCode}');
debugPrint('[VersionChecker] 响应数据: ${response.data}');
if (response.statusCode == 200 && response.data != null) {
//
final needUpdate = response.data['needUpdate'] as bool? ?? true;
if (!needUpdate) {
debugPrint('[VersionChecker] 服务器返回无需更新');
return null;
}
debugPrint('[VersionChecker] 服务器返回需要更新');
return VersionInfo.fromJson(response.data);
}
return null;
} catch (e) {
debugPrint('Fetch version failed: $e');
debugPrint('[VersionChecker] 获取版本失败: $e');
return null;
}
}

View File

@ -69,14 +69,8 @@ class _SplashPageState extends ConsumerState<SplashPage> {
context.go(RoutePaths.onboarding);
}
//
final targetRoute = authState.isWalletCreated ? RoutePaths.ranking : null;
//
if (targetRoute == RoutePaths.ranking) {
//
checkForAppUpdate(context);
}
//
checkForAppUpdate(context);
}
@override