Commit d13cd4c8e3e73bc050aaaa0b32c981418253e272

Authored by 权海
1 parent 57c728d2

feat(ui):登录进入app前向原生同步信息的部分代码不用await

(cherry picked from commit 71aab30e)

# Conflicts:
#	lib/app/bootstrap/app_bootstrap.dart
... ... @@ -44,7 +44,11 @@ abstract final class AppBootstrap {
localStorage: local,
).dependencies();
await userPreferencesStorage.syncLoginInfoToNative();
// `UserPreferencesStorage.init` runs before GetX dependencies exist. Sync
// here so every cold start invokes native `updateLoginInfo` after the
// PlatformHostApi and HealthRawDataCoreService are ready.
unawaited(userPreferencesStorage.syncLoginInfoToNative());
NativeHealthDataUpdateBridge.initialize();
LoadingService.init();
... ... @@ -84,6 +88,8 @@ abstract final class AppBootstrap {
localStorage: local,
).dependencies();
unawaited(userPreferencesStorage.syncLoginInfoToNative());
NativeHealthDataUpdateBridge.initialize();
// 2. 后台无 UI,不需要初始化全局 Loading 弹窗
LoadingService.init();
... ...
... ... @@ -631,7 +631,9 @@ class LoginController extends GetxController {
try {
if (Get.isRegistered<AppEnvironmentConfig>()) {
var env = Get.find<AppEnvironmentConfig>();
await AppPlatformHostApi().updateLoginInfo(
unawaited(
AppPlatformHostApi()
.updateLoginInfo(
jsonEncode(UserPreferences(
accessToken: accessToken,
meUserInfo: me,
... ... @@ -640,7 +642,12 @@ class LoginController extends GetxController {
? UserPreferencesVipInfo.fromVipInfo(vip)
: null,
)),
env.serverBaseUrl);
env.serverBaseUrl,
)
.catchError((Object error, StackTrace stackTrace) {
AppLogger.e('Native login info sync failed', error, stackTrace);
}),
);
}
} on Exception catch (e) {
AppLogger.e(e);
... ...
import 'dart:async';
import 'dart:convert';
import 'package:doublefeel_flutter/core/config/app_environment_config.dart';
... ... @@ -143,7 +144,9 @@ class UserPreferencesStorage {
vipInfo: vip != null ? UserPreferencesVipInfo.fromVipInfo(vip) : null,
);
await _persist(userInfo);
await _syncLoginInfoToNative(userInfo: userInfo);
// Native login/health database synchronization is best effort and can
// trigger expensive platform work. Do not hold the login transition for it.
unawaited(_syncLoginInfoToNative(userInfo: userInfo));
}
Future<void> clearPartnerUserInfo() async {
... ...