mirror of
https://gitlab.com/mysocialportal/relatica
synced 2024-10-18 13:33:32 +00:00
Fix profiles loading error
This commit is contained in:
parent
e0cd3ccaf5
commit
08b595bc4d
2 changed files with 10 additions and 7 deletions
|
@ -34,7 +34,8 @@ class AccountsService extends ChangeNotifier {
|
|||
final lastActiveProfile = await _getStoredLoginState();
|
||||
|
||||
final result = await runCatchingAsync(() async {
|
||||
for (final p in secretsService.profiles) {
|
||||
final initialProfiles = secretsService.profiles;
|
||||
for (final p in initialProfiles) {
|
||||
if (!p.loggedIn) {
|
||||
_loggedOutProfiles.add(p);
|
||||
continue;
|
||||
|
@ -50,7 +51,7 @@ class AccountsService extends ChangeNotifier {
|
|||
}
|
||||
|
||||
if (_currentProfile == null && _loggedInProfiles.isNotEmpty) {
|
||||
setActiveProfile(_loggedInProfiles.first);
|
||||
await setActiveProfile(_loggedInProfiles.first);
|
||||
}
|
||||
|
||||
return Result.ok(loggedIn);
|
||||
|
@ -79,11 +80,12 @@ class AccountsService extends ChangeNotifier {
|
|||
);
|
||||
|
||||
if (_loggedInProfiles.isEmpty) {
|
||||
setActiveProfile(loginProfile, withNotification: withNotification);
|
||||
await setActiveProfile(loginProfile,
|
||||
withNotification: withNotification);
|
||||
}
|
||||
_loggedInProfiles.add(loginProfile);
|
||||
_loggedOutProfiles.remove(loginProfile);
|
||||
secretsService.addOrUpdateProfile(loginProfile);
|
||||
await secretsService.addOrUpdateProfile(loginProfile);
|
||||
if (withNotification) {
|
||||
notifyListeners();
|
||||
}
|
||||
|
@ -99,11 +101,11 @@ class AccountsService extends ChangeNotifier {
|
|||
|
||||
Future signOut(Profile profile, {bool withNotification = true}) async {
|
||||
if (_currentProfile == profile) {
|
||||
clearActiveProfile(withNotification: withNotification);
|
||||
await clearActiveProfile(withNotification: withNotification);
|
||||
}
|
||||
_loggedInProfiles.remove(profile);
|
||||
_loggedOutProfiles.add(profile.copyWithLoginUpdate(false));
|
||||
secretsService.addOrUpdateProfile(profile.copyWithLoginUpdate(false));
|
||||
await secretsService.addOrUpdateProfile(profile.copyWithLoginUpdate(false));
|
||||
|
||||
if (_loggedInProfiles.isNotEmpty) {
|
||||
setActiveProfile(
|
||||
|
|
|
@ -15,7 +15,8 @@ class SecretsService {
|
|||
|
||||
final _cachedProfiles = <Profile>{};
|
||||
|
||||
List<Profile> get profiles => UnmodifiableListView(_cachedProfiles);
|
||||
List<Profile> get profiles =>
|
||||
UnmodifiableListView(List.from(_cachedProfiles));
|
||||
|
||||
final _secureStorage = const FlutterSecureStorage(
|
||||
iOptions: IOSOptions(
|
||||
|
|
Loading…
Reference in a new issue