This commit is contained in:
Sorunome 2020-07-24 14:53:06 +02:00
parent ad8135990d
commit ff2de35d28
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
2 changed files with 15 additions and 10 deletions

View File

@ -41,9 +41,10 @@ class MatrixEvent extends StrippedStateEvent {
unsigned = json['unsigned'] != null unsigned = json['unsigned'] != null
? Map<String, dynamic>.from(json['unsigned']) ? Map<String, dynamic>.from(json['unsigned'])
: null; : null;
prevContent = json['prev_content'] != null prevContent =
? Map<String, dynamic>.from(json['prev_content']) json.containsKey('prev_content') && json['prev_content'] != null
: null; ? Map<String, dynamic>.from(json['prev_content'])
: null;
redacts = json['redacts']; redacts = json['redacts'];
} }

View File

@ -93,7 +93,9 @@ class Event extends MatrixEvent {
// into the unsigned block // into the unsigned block
this.prevContent = prevContent != null && prevContent.isNotEmpty this.prevContent = prevContent != null && prevContent.isNotEmpty
? prevContent ? prevContent
: (unsigned != null && unsigned['prev_content'] is Map : (unsigned != null &&
unsigned.containsKey('prev_content') &&
unsigned['prev_content'] is Map
? unsigned['prev_content'] ? unsigned['prev_content']
: null); : null);
this.stateKey = stateKey; this.stateKey = stateKey;
@ -481,7 +483,8 @@ class Event extends MatrixEvent {
final targetName = stateKeyUser.calcDisplayname(); final targetName = stateKeyUser.calcDisplayname();
// Has the membership changed? // Has the membership changed?
final newMembership = content['membership'] ?? ''; final newMembership = content['membership'] ?? '';
final oldMembership = unsigned['prev_content'] is Map<String, dynamic> final oldMembership = unsigned.containsKey('prev_content') &&
unsigned['prev_content'] is Map<String, dynamic>
? unsigned['prev_content']['membership'] ?? '' ? unsigned['prev_content']['membership'] ?? ''
: ''; : '';
if (newMembership != oldMembership) { if (newMembership != oldMembership) {
@ -518,15 +521,16 @@ class Event extends MatrixEvent {
} }
} else if (newMembership == 'join') { } else if (newMembership == 'join') {
final newAvatar = content['avatar_url'] ?? ''; final newAvatar = content['avatar_url'] ?? '';
final oldAvatar = unsigned['prev_content'] is Map<String, dynamic> final oldAvatar = unsigned.containsKey('prev_content') &&
unsigned['prev_content'] is Map<String, dynamic>
? unsigned['prev_content']['avatar_url'] ?? '' ? unsigned['prev_content']['avatar_url'] ?? ''
: ''; : '';
final newDisplayname = content['displayname'] ?? ''; final newDisplayname = content['displayname'] ?? '';
final oldDisplayname = final oldDisplayname = unsigned.containsKey('prev_content') &&
unsigned['prev_content'] is Map<String, dynamic> unsigned['prev_content'] is Map<String, dynamic>
? unsigned['prev_content']['displayname'] ?? '' ? unsigned['prev_content']['displayname'] ?? ''
: ''; : '';
// Has the user avatar changed? // Has the user avatar changed?
if (newAvatar != oldAvatar) { if (newAvatar != oldAvatar) {