diff --git a/lib/main.dart b/lib/main.dart index 16e1d2c8..ad8fd3f3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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); diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index 78234ad9..3492b205 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -136,17 +136,19 @@ class MatrixState extends State 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((_) { - widget.clients.add(_loginClientCandidate); + 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 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'); }); }