From d1203c53a2d8ec899007dff20bc8e6b0b4bd7282 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Mon, 27 Feb 2023 14:55:39 -0500 Subject: [PATCH] Add proper login/out storage/processing on load --- lib/services/auth_service.dart | 5 +++-- lib/services/secrets_service.dart | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/services/auth_service.dart b/lib/services/auth_service.dart index 054f487..bb9e645 100644 --- a/lib/services/auth_service.dart +++ b/lib/services/auth_service.dart @@ -37,6 +37,7 @@ class AccountsService extends ChangeNotifier { for (final p in secretsService.profiles) { if (!p.loggedIn) { _loggedOutProfiles.add(p); + continue; } final pr = await signIn(p.credentials, withNotification: false); @@ -74,7 +75,6 @@ class AccountsService extends ChangeNotifier { serverName: credentialsCache!.serverName, avatar: profileData.avatarUrl, userId: profileData.id, - id: credentials.id, loggedIn: true, ); @@ -102,7 +102,8 @@ class AccountsService extends ChangeNotifier { clearActiveProfile(withNotification: withNotification); } _loggedInProfiles.remove(profile); - secretsService.addOrUpdateProfile(profile); + _loggedOutProfiles.add(profile.copyWithLoginUpdate(false)); + secretsService.addOrUpdateProfile(profile.copyWithLoginUpdate(false)); if (_loggedInProfiles.isNotEmpty) { setActiveProfile( diff --git a/lib/services/secrets_service.dart b/lib/services/secrets_service.dart index 3a6ffeb..8908599 100644 --- a/lib/services/secrets_service.dart +++ b/lib/services/secrets_service.dart @@ -43,6 +43,7 @@ class SecretsService { FutureResult, ExecError> addOrUpdateProfile( Profile profile) async { try { + _cachedProfiles.remove(profile); _cachedProfiles.add(profile); return await saveCredentials(); } on PlatformException catch (e) {