kopia lustrzana https://gitlab.com/mysocialportal/relatica
Fix cycling of multiple logins on app startup
rodzic
4eba9eb6a9
commit
1e6b16291a
|
@ -103,7 +103,7 @@ class CredentialSignin extends _$CredentialSignin {
|
|||
return false;
|
||||
}
|
||||
|
||||
FutureResult<Profile, ExecError> signIn() async {
|
||||
FutureResult<Profile, ExecError> signIn(bool activateProfileOnSuccess) async {
|
||||
final result =
|
||||
await credentials.signIn(ref).andThenAsync((signedInCredentials) async {
|
||||
ref.read(statusServiceProvider.notifier).setStatus(
|
||||
|
@ -126,7 +126,7 @@ class CredentialSignin extends _$CredentialSignin {
|
|||
ref
|
||||
.read(statusServiceProvider.notifier)
|
||||
.setStatus('Loaded user profile ${profileData.handle}');
|
||||
if (ref.read(loggedInProfilesProvider).isEmpty) {
|
||||
if (activateProfileOnSuccess) {
|
||||
ref.read(activeProfileProvider.notifier).setActiveProfile(loginProfile);
|
||||
}
|
||||
ref.read(loggedInProfilesProvider.notifier).add(loginProfile);
|
||||
|
@ -158,10 +158,10 @@ class ProfileManager extends _$ProfileManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
FutureResult<Profile, ExecError> signIn() async {
|
||||
FutureResult<Profile, ExecError> signIn(bool activateProfileOnSuccess) async {
|
||||
return await ref
|
||||
.read(credentialSigninProvider(profile.credentials).notifier)
|
||||
.signIn();
|
||||
.signIn(activateProfileOnSuccess);
|
||||
}
|
||||
|
||||
Future signOut({bool withNotification = true}) async {
|
||||
|
@ -218,7 +218,8 @@ class AccountServicesInitializer extends _$AccountServicesInitializer {
|
|||
continue;
|
||||
}
|
||||
|
||||
final pr = await ref.read(profileManagerProvider(p).notifier).signIn();
|
||||
final pr =
|
||||
await ref.read(profileManagerProvider(p).notifier).signIn(false);
|
||||
if (pr.isSuccess) {
|
||||
final profile = pr.value;
|
||||
if (profile.id.isNotEmpty && profile.id == lastActiveProfile) {
|
||||
|
|
|
@ -444,7 +444,7 @@ class _SignInScreenState extends ConsumerState<SignInScreen> {
|
|||
|
||||
buildSnackbar(context, 'Attempting to sign in account...');
|
||||
final result =
|
||||
await ref.read(credentialSigninProvider(creds).notifier).signIn();
|
||||
await ref.read(credentialSigninProvider(creds).notifier).signIn(true);
|
||||
|
||||
if (context.mounted && result.isFailure) {
|
||||
buildSnackbar(context, 'Error signing in: ${result.error}');
|
||||
|
|
Ładowanie…
Reference in New Issue