Commit 71aab30ebfd469a43a6add20ed9c5f0a6cd939d9

Authored by 权海
1 parent 2a36f177

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

... ... @@ -47,7 +47,7 @@ abstract final class AppBootstrap {
// `UserPreferencesStorage.init` runs before GetX dependencies exist. Sync
// here so every cold start invokes native `updateLoginInfo` after the
// PlatformHostApi and HealthRawDataCoreService are ready.
await userPreferencesStorage.syncLoginInfoToNative();
unawaited(userPreferencesStorage.syncLoginInfoToNative());
NativeHealthDataUpdateBridge.initialize();
... ... @@ -88,7 +88,7 @@ abstract final class AppBootstrap {
localStorage: local,
).dependencies();
await userPreferencesStorage.syncLoginInfoToNative();
unawaited(userPreferencesStorage.syncLoginInfoToNative());
NativeHealthDataUpdateBridge.initialize();
// 2. 后台无 UI,不需要初始化全局 Loading 弹窗
... ...
... ... @@ -641,7 +641,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,
... ... @@ -650,7 +652,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';
... ... @@ -144,7 +145,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 {
... ...