Fix profiles loading error

codemagic-setup
Hank Grabowski 2023-02-27 16:05:46 -05:00
rodzic e0cd3ccaf5
commit 08b595bc4d
2 zmienionych plików z 10 dodań i 7 usunięć

Wyświetl plik

@ -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(

Wyświetl plik

@ -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(