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);
|
Zone.current.handleUncaughtError(details.exception, details.stack);
|
||||||
|
|
||||||
final clients = await ClientManager.getClients();
|
final clients = await ClientManager.getClients();
|
||||||
|
Logs().level = kDebugMode ? Level.debug : Level.warning;
|
||||||
|
|
||||||
if (PlatformInfos.isMobile) {
|
if (PlatformInfos.isMobile) {
|
||||||
BackgroundPush.clientOnly(clients.first);
|
BackgroundPush.clientOnly(clients.first);
|
||||||
|
@ -136,17 +136,19 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||||||
Client _loginClientCandidate;
|
Client _loginClientCandidate;
|
||||||
|
|
||||||
Client getLoginClient() {
|
Client getLoginClient() {
|
||||||
final multiAccount = client.isLogged();
|
if (widget.clients.isNotEmpty && !client.isLogged()) {
|
||||||
if (!multiAccount) return client;
|
return client;
|
||||||
|
}
|
||||||
_loginClientCandidate ??= ClientManager.createClient(
|
_loginClientCandidate ??= ClientManager.createClient(
|
||||||
// we use the first clients here, else we can easily end up with super long client names.
|
'${AppConfig.applicationName}-${DateTime.now().millisecondsSinceEpoch}')
|
||||||
widget.clients.first.generateUniqueTransactionId())
|
|
||||||
..onLoginStateChanged
|
..onLoginStateChanged
|
||||||
.stream
|
.stream
|
||||||
.where((l) => l == LoginState.loggedIn)
|
.where((l) => l == LoginState.loggedIn)
|
||||||
.first
|
.first
|
||||||
.then((_) {
|
.then((_) {
|
||||||
|
if (!widget.clients.contains(_loginClientCandidate)) {
|
||||||
widget.clients.add(_loginClientCandidate);
|
widget.clients.add(_loginClientCandidate);
|
||||||
|
}
|
||||||
ClientManager.addClientNameToStore(_loginClientCandidate.clientName);
|
ClientManager.addClientNameToStore(_loginClientCandidate.clientName);
|
||||||
_registerSubs(_loginClientCandidate.clientName);
|
_registerSubs(_loginClientCandidate.clientName);
|
||||||
_loginClientCandidate = null;
|
_loginClientCandidate = null;
|
||||||
@ -207,12 +209,12 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||||||
String get cachedPassword => _cachedPassword;
|
String get cachedPassword => _cachedPassword;
|
||||||
|
|
||||||
set cachedPassword(String p) {
|
set cachedPassword(String p) {
|
||||||
Logs().v('Password cached');
|
Logs().d('Password cached');
|
||||||
_cachedPasswordClearTimer?.cancel();
|
_cachedPasswordClearTimer?.cancel();
|
||||||
_cachedPassword = p;
|
_cachedPassword = p;
|
||||||
_cachedPasswordClearTimer = Timer(const Duration(minutes: 10), () {
|
_cachedPasswordClearTimer = Timer(const Duration(minutes: 10), () {
|
||||||
_cachedPassword = null;
|
_cachedPassword = null;
|
||||||
Logs().v('Cached Password cleared');
|
Logs().d('Cached Password cleared');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user