refactor: Follow up handle logout and login with new client
This commit is contained in:
parent
2ba5b1170d
commit
2616ba6e4b
5 changed files with 26 additions and 15 deletions
|
|
@ -174,6 +174,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
_loginClientCandidate = null;
|
||||
FluffyChatApp.router.go('/rooms');
|
||||
});
|
||||
if (widget.clients.isEmpty) widget.clients.add(candidate);
|
||||
return candidate;
|
||||
}
|
||||
|
||||
|
|
@ -282,12 +283,12 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
onLoginStateChanged[name] ??= c.onLoginStateChanged.stream.listen((state) {
|
||||
final loggedInWithMultipleClients = widget.clients.length > 1;
|
||||
if (state == LoginState.loggedOut) {
|
||||
InitWithRestoreExtension.deleteSessionBackup(name);
|
||||
}
|
||||
if (loggedInWithMultipleClients && state != LoginState.loggedIn) {
|
||||
_cancelSubs(c.clientName);
|
||||
widget.clients.remove(c);
|
||||
ClientManager.removeClientNameFromStore(c.clientName, store);
|
||||
InitWithRestoreExtension.deleteSessionBackup(name);
|
||||
}
|
||||
if (loggedInWithMultipleClients && state != LoginState.loggedIn) {
|
||||
ScaffoldMessenger.of(
|
||||
FluffyChatApp.router.routerDelegate.navigatorKey.currentContext ??
|
||||
context,
|
||||
|
|
@ -379,12 +380,14 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
Logs().v('AppLifecycleState = $state');
|
||||
final foreground = state != AppLifecycleState.inactive &&
|
||||
state != AppLifecycleState.paused;
|
||||
client.syncPresence =
|
||||
state == AppLifecycleState.resumed ? null : PresenceType.unavailable;
|
||||
if (PlatformInfos.isMobile) {
|
||||
client.backgroundSync = foreground;
|
||||
client.requestHistoryOnLimitedTimeline = !foreground;
|
||||
Logs().v('Set background sync to', foreground);
|
||||
for (final client in widget.clients) {
|
||||
client.syncPresence =
|
||||
state == AppLifecycleState.resumed ? null : PresenceType.unavailable;
|
||||
if (PlatformInfos.isMobile) {
|
||||
client.backgroundSync = foreground;
|
||||
client.requestHistoryOnLimitedTimeline = !foreground;
|
||||
Logs().v('Set background sync to', foreground);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue