Fix prev_content bug

This commit is contained in:
Christian Pauly 2020-08-04 10:07:46 +02:00
parent d4a7345b8a
commit fe700b229c

View file

@ -99,9 +99,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['prev_content'] is Map)
? unsigned['prev_content'] ? unsigned['prev_content']
: null); : null;
this.stateKey = stateKey; this.stateKey = stateKey;
this.originServerTs = originServerTs; this.originServerTs = originServerTs;
} }
@ -477,9 +477,7 @@ class Event extends MatrixEvent {
// Has the membership changed? // Has the membership changed?
final newMembership = content['membership'] ?? ''; final newMembership = content['membership'] ?? '';
final oldMembership = final oldMembership =
unsigned != null && unsigned['prev_content'] is Map<String, dynamic> prevContent != null ? prevContent['membership'] ?? '' : '';
? unsigned['prev_content']['membership'] ?? ''
: '';
if (newMembership != oldMembership) { if (newMembership != oldMembership) {
if (oldMembership == 'invite' && newMembership == 'join') { if (oldMembership == 'invite' && newMembership == 'join') {
text = i18n.acceptedTheInvitation(targetName); text = i18n.acceptedTheInvitation(targetName);
@ -514,16 +512,12 @@ 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 != null && final oldAvatar =
unsigned['prev_content'] is Map<String, dynamic> prevContent != null ? prevContent['avatar_url'] ?? '' : '';
? unsigned['prev_content']['avatar_url'] ?? ''
: '';
final newDisplayname = content['displayname'] ?? ''; final newDisplayname = content['displayname'] ?? '';
final oldDisplayname = unsigned != null && final oldDisplayname =
unsigned['prev_content'] is Map<String, dynamic> prevContent != null ? prevContent['displayname'] ?? '' : '';
? unsigned['prev_content']['displayname'] ?? ''
: '';
// Has the user avatar changed? // Has the user avatar changed?
if (newAvatar != oldAvatar) { if (newAvatar != oldAvatar) {