merged develop
This commit is contained in:
@@ -10,8 +10,7 @@ import '../api/marianumconnect/queries/auth_logout/auth_logout.dart';
|
||||
import '../api/marianumconnect/queries/auth_me/auth_me.dart';
|
||||
import '../auth_link/guardian_link_listener.dart';
|
||||
import '../background/widget_background_task.dart';
|
||||
import '../push/chat_thread_store.dart';
|
||||
import '../push/nid_store.dart';
|
||||
import '../model/session_wipe.dart';
|
||||
import '../push/push_registration.dart';
|
||||
import '../storage/account_storage.dart';
|
||||
import '../widget_data/widget_sync.dart';
|
||||
@@ -41,10 +40,11 @@ abstract final class SessionLifecycle {
|
||||
}
|
||||
await AuthLogout().run();
|
||||
final removed = await SessionManager().signOut();
|
||||
SessionWipe.clearImmediate();
|
||||
// A login link that arrived while signed in must not be replayed on the
|
||||
// login screen that follows.
|
||||
GuardianLinkListener.clear();
|
||||
await _clearPushStores();
|
||||
await SessionWipe.accountLeft();
|
||||
if (removed != null) await AccountStorage.delete(removed.namespace);
|
||||
|
||||
for (
|
||||
@@ -78,14 +78,22 @@ abstract final class SessionLifecycle {
|
||||
log('Switch: push deactivation failed: $e');
|
||||
}
|
||||
await SessionManager().stashActive();
|
||||
SessionWipe.clearImmediate();
|
||||
var restored = false;
|
||||
try {
|
||||
await SessionManager().activate(id);
|
||||
} on Object {
|
||||
if (previous != null) await SessionManager().activate(previous.id);
|
||||
if (previous != null) {
|
||||
await SessionManager().activate(previous.id);
|
||||
restored = true;
|
||||
}
|
||||
rethrow;
|
||||
} finally {
|
||||
await _clearPushStores();
|
||||
await SessionWipe.accountLeft();
|
||||
await AccountStorage.activate(SessionManager().activeAccount);
|
||||
// Nothing remounts for the account that stays, so its push would
|
||||
// remain unregistered until the next start.
|
||||
if (restored) unawaited(PushRegistration().register());
|
||||
}
|
||||
await _resetWidget();
|
||||
}
|
||||
@@ -94,6 +102,10 @@ abstract final class SessionLifecycle {
|
||||
static Future<void> beginAddAccount() async {
|
||||
await SessionManager().stashActive();
|
||||
_addReturnId = SessionManager().activeAccount?.id;
|
||||
SessionWipe.clearImmediate();
|
||||
// Whatever runs behind the login screen must not write into the parked
|
||||
// account's data.
|
||||
await AccountStorage.activate(null);
|
||||
}
|
||||
|
||||
static bool get isAddingAccount => _addReturnId != null;
|
||||
@@ -109,6 +121,7 @@ abstract final class SessionLifecycle {
|
||||
await SessionManager().signOut();
|
||||
}
|
||||
await SessionManager().activate(returnId);
|
||||
await AccountStorage.activate(SessionManager().activeAccount);
|
||||
}
|
||||
|
||||
/// Called once a login finished. After "add account" the previous account's
|
||||
@@ -127,7 +140,7 @@ abstract final class SessionLifecycle {
|
||||
log('Add account: push deactivation failed: $e');
|
||||
}
|
||||
await SessionManager().activate(added.id);
|
||||
await _clearPushStores();
|
||||
await SessionWipe.accountLeft();
|
||||
}
|
||||
await AccountStorage.activate(SessionManager().activeAccount);
|
||||
return added.id;
|
||||
@@ -191,14 +204,4 @@ abstract final class SessionLifecycle {
|
||||
log('Widget reset failed: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// Tray bookkeeping of the previous account's pushes.
|
||||
static Future<void> _clearPushStores() async {
|
||||
try {
|
||||
await NidStore().clear();
|
||||
await ChatThreadStore().clearAll();
|
||||
} on Object catch (e) {
|
||||
log('Push store cleanup failed: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user