mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 14:59:29 +01:00
fix: Crash on logout
This commit is contained in:
parent
6b68020857
commit
288160d852
@ -37,6 +37,7 @@ void main() async {
|
||||
Zone.current.handleUncaughtError(details.exception, details.stack);
|
||||
|
||||
final clients = await ClientManager.getClients();
|
||||
Logs().level = kDebugMode ? Level.debug : Level.warning;
|
||||
|
||||
if (PlatformInfos.isMobile) {
|
||||
BackgroundPush.clientOnly(clients.first);
|
||||
|
@ -136,17 +136,19 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||
Client _loginClientCandidate;
|
||||
|
||||
Client getLoginClient() {
|
||||
final multiAccount = client.isLogged();
|
||||
if (!multiAccount) return client;
|
||||
if (widget.clients.isNotEmpty && !client.isLogged()) {
|
||||
return client;
|
||||
}
|
||||
_loginClientCandidate ??= ClientManager.createClient(
|
||||
// we use the first clients here, else we can easily end up with super long client names.
|
||||
widget.clients.first.generateUniqueTransactionId())
|
||||
'${AppConfig.applicationName}-${DateTime.now().millisecondsSinceEpoch}')
|
||||
..onLoginStateChanged
|
||||
.stream
|
||||
.where((l) => l == LoginState.loggedIn)
|
||||
.first
|
||||
.then((_) {
|
||||
if (!widget.clients.contains(_loginClientCandidate)) {
|
||||
widget.clients.add(_loginClientCandidate);
|
||||
}
|
||||
ClientManager.addClientNameToStore(_loginClientCandidate.clientName);
|
||||
_registerSubs(_loginClientCandidate.clientName);
|
||||
_loginClientCandidate = null;
|
||||
@ -207,12 +209,12 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||
String get cachedPassword => _cachedPassword;
|
||||
|
||||
set cachedPassword(String p) {
|
||||
Logs().v('Password cached');
|
||||
Logs().d('Password cached');
|
||||
_cachedPasswordClearTimer?.cancel();
|
||||
_cachedPassword = p;
|
||||
_cachedPasswordClearTimer = Timer(const Duration(minutes: 10), () {
|
||||
_cachedPassword = null;
|
||||
Logs().v('Cached Password cleared');
|
||||
Logs().d('Cached Password cleared');
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user