From 8908f333937d902bff184e8529a79a0c4ef1d18b Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Thu, 15 Oct 2020 09:08:49 +0200 Subject: [PATCH 1/2] fix: Logout from outside --- lib/src/client.dart | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index ff23881..e75d5d0 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -509,10 +509,6 @@ class Client extends MatrixApi { final StreamController onLoginStateChanged = StreamController.broadcast(); - /// Synchronization erros are coming here. - final StreamController onError = - StreamController.broadcast(); - /// Synchronization erros are coming here. final StreamController onSyncError = StreamController.broadcast(); @@ -756,18 +752,17 @@ class Client extends MatrixApi { encryption.onSync(); } _retryDelay = Future.value(); - } on MatrixException catch (e) { - onError.add(e); + } on MatrixException catch (e, s) { + onSyncError.add(SdkError(exception: e, stackTrace: s)); + if (e.error == MatrixError.M_UNKNOWN_TOKEN) { + Logs.warning('The user has been logged out!'); + clear(); + } } catch (e, s) { if (!isLogged() || _disposed) return; Logs.error('Error during processing events: ' + e.toString(), s); onSyncError.add(SdkError( exception: e is Exception ? e : Exception(e), stackTrace: s)); - if (e is MatrixException && - e.errcode == MatrixError.M_UNKNOWN_TOKEN.toString().split('.').last) { - Logs.warning('The user has been logged out!'); - clear(); - } } } From 9632d68b92554f6791af981341fe5cf0b61f9982 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Sat, 17 Oct 2020 11:16:43 +0200 Subject: [PATCH 2/2] fix: one itme keys response failure may be null --- lib/matrix_api/model/one_time_keys_claim_response.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matrix_api/model/one_time_keys_claim_response.dart b/lib/matrix_api/model/one_time_keys_claim_response.dart index 501fd48..7834211 100644 --- a/lib/matrix_api/model/one_time_keys_claim_response.dart +++ b/lib/matrix_api/model/one_time_keys_claim_response.dart @@ -21,7 +21,7 @@ class OneTimeKeysClaimResponse { Map> oneTimeKeys; OneTimeKeysClaimResponse.fromJson(Map json) { - failures = Map.from(json['failures']); + failures = Map.from(json['failures'] ?? {}); oneTimeKeys = Map>.from(json['one_time_keys']); }