From 9cb4dab9d41756b81e63ef0e8e484bb3ce609479 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Fri, 24 Jul 2020 15:37:00 +0200 Subject: [PATCH 1/3] test web --- lib/matrix_api/model/matrix_event.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/matrix_api/model/matrix_event.dart b/lib/matrix_api/model/matrix_event.dart index 0a20bf5..e70f8b5 100644 --- a/lib/matrix_api/model/matrix_event.dart +++ b/lib/matrix_api/model/matrix_event.dart @@ -41,10 +41,9 @@ class MatrixEvent extends StrippedStateEvent { unsigned = json['unsigned'] != null ? Map.from(json['unsigned']) : null; - prevContent = - json.containsKey('prev_content') && json['prev_content'] != null - ? Map.from(json['prev_content']) - : null; + prevContent = json['prev_content'] != null + ? Map.from(json['prev_content']) + : null; redacts = json['redacts']; } From d4818bd67789cf011ba36b17cefa9b86d5d76bcc Mon Sep 17 00:00:00 2001 From: Sorunome Date: Fri, 24 Jul 2020 15:37:40 +0200 Subject: [PATCH 2/3] forgot to ctrl+s --- lib/src/event.dart | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/src/event.dart b/lib/src/event.dart index 154f090..45f9d03 100644 --- a/lib/src/event.dart +++ b/lib/src/event.dart @@ -93,9 +93,7 @@ class Event extends MatrixEvent { // into the unsigned block this.prevContent = prevContent != null && prevContent.isNotEmpty ? prevContent - : (unsigned != null && - unsigned.containsKey('prev_content') && - unsigned['prev_content'] is Map + : (unsigned != null && unsigned['prev_content'] is Map ? unsigned['prev_content'] : null); this.stateKey = stateKey; @@ -483,8 +481,7 @@ class Event extends MatrixEvent { final targetName = stateKeyUser.calcDisplayname(); // Has the membership changed? final newMembership = content['membership'] ?? ''; - final oldMembership = unsigned.containsKey('prev_content') && - unsigned['prev_content'] is Map + final oldMembership = unsigned != null && unsigned['prev_content'] is Map ? unsigned['prev_content']['membership'] ?? '' : ''; if (newMembership != oldMembership) { @@ -521,14 +518,12 @@ class Event extends MatrixEvent { } } else if (newMembership == 'join') { final newAvatar = content['avatar_url'] ?? ''; - final oldAvatar = unsigned.containsKey('prev_content') && - unsigned['prev_content'] is Map + final oldAvatar = unsigned != null && unsigned['prev_content'] is Map ? unsigned['prev_content']['avatar_url'] ?? '' : ''; final newDisplayname = content['displayname'] ?? ''; - final oldDisplayname = unsigned.containsKey('prev_content') && - unsigned['prev_content'] is Map + final oldDisplayname = unsigned != null && unsigned['prev_content'] is Map ? unsigned['prev_content']['displayname'] ?? '' : ''; From 84a94f5c9df1aaabe864d7fdb4a149b279f89d14 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Fri, 24 Jul 2020 15:44:55 +0200 Subject: [PATCH 3/3] format --- lib/src/event.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/src/event.dart b/lib/src/event.dart index 45f9d03..47ca3d0 100644 --- a/lib/src/event.dart +++ b/lib/src/event.dart @@ -481,9 +481,10 @@ class Event extends MatrixEvent { final targetName = stateKeyUser.calcDisplayname(); // Has the membership changed? final newMembership = content['membership'] ?? ''; - final oldMembership = unsigned != null && unsigned['prev_content'] is Map - ? unsigned['prev_content']['membership'] ?? '' - : ''; + final oldMembership = + unsigned != null && unsigned['prev_content'] is Map + ? unsigned['prev_content']['membership'] ?? '' + : ''; if (newMembership != oldMembership) { if (oldMembership == 'invite' && newMembership == 'join') { text = i18n.acceptedTheInvitation(targetName); @@ -518,12 +519,14 @@ class Event extends MatrixEvent { } } else if (newMembership == 'join') { final newAvatar = content['avatar_url'] ?? ''; - final oldAvatar = unsigned != null && unsigned['prev_content'] is Map + final oldAvatar = unsigned != null && + unsigned['prev_content'] is Map ? unsigned['prev_content']['avatar_url'] ?? '' : ''; final newDisplayname = content['displayname'] ?? ''; - final oldDisplayname = unsigned != null && unsigned['prev_content'] is Map + final oldDisplayname = unsigned != null && + unsigned['prev_content'] is Map ? unsigned['prev_content']['displayname'] ?? '' : '';