mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
fix(mobile): freeze on splash screen due to accessing bad state (#998)
This commit is contained in:
@@ -90,6 +90,7 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||
|
||||
return setSuccessLoginInfo(
|
||||
accessToken: loginResponse.accessToken,
|
||||
serverUrl: serverEndpoint,
|
||||
isSavedLoginInfo: isSavedLoginInfo,
|
||||
);
|
||||
} catch (e) {
|
||||
@@ -159,16 +160,18 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||
|
||||
Future<bool> setSuccessLoginInfo({
|
||||
required String accessToken,
|
||||
required String serverUrl,
|
||||
required bool isSavedLoginInfo,
|
||||
}) async {
|
||||
Hive.box(userInfoBox).put(accessTokenKey, accessToken);
|
||||
|
||||
_apiService.setAccessToken(accessToken);
|
||||
var userResponseDto = await _apiService.userApi.getMyUserInfo();
|
||||
|
||||
if (userResponseDto != null) {
|
||||
var userInfoHiveBox = await Hive.openBox(userInfoBox);
|
||||
var deviceInfo = await _deviceInfoService.getDeviceInfo();
|
||||
Hive.box(userInfoBox).put(deviceIdKey, deviceInfo["deviceId"]);
|
||||
userInfoHiveBox.put(deviceIdKey, deviceInfo["deviceId"]);
|
||||
userInfoHiveBox.put(accessTokenKey, accessToken);
|
||||
userInfoHiveBox.put(serverEndpointKey, serverUrl);
|
||||
|
||||
state = state.copyWith(
|
||||
isAuthenticated: true,
|
||||
@@ -191,7 +194,7 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||
email: "",
|
||||
password: "",
|
||||
isSaveLogin: true,
|
||||
serverUrl: Hive.box(userInfoBox).get(serverEndpointKey),
|
||||
serverUrl: serverUrl,
|
||||
accessToken: accessToken,
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user