use prev_content to calculate displayname and avatar_url, if content unavailable
This commit is contained in:
parent
26510173de
commit
864151ec83
|
@ -89,7 +89,13 @@ class Event extends MatrixEvent {
|
|||
this.roomId = roomId ?? room?.id;
|
||||
this.senderId = senderId;
|
||||
this.unsigned = unsigned;
|
||||
this.prevContent = prevContent;
|
||||
// synapse unfortunatley isn't following the spec and tosses the prev_content
|
||||
// into the unsigned block
|
||||
this.prevContent = prevContent != null && prevContent.isNotEmpty
|
||||
? prevContent
|
||||
: (unsigned != null && unsigned['prev_content'] is Map
|
||||
? unsigned['prev_content']
|
||||
: null);
|
||||
this.stateKey = stateKey;
|
||||
this.originServerTs = originServerTs;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,10 @@ class User extends Event {
|
|||
String get id => stateKey;
|
||||
|
||||
/// The displayname of the user if the user has set one.
|
||||
String get displayName => content != null ? content['displayname'] : null;
|
||||
String get displayName =>
|
||||
content != null && content.containsKey('displayname')
|
||||
? content['displayname']
|
||||
: (prevContent != null ? prevContent['displayname'] : null);
|
||||
|
||||
/// Returns the power level of this user.
|
||||
int get powerLevel => room?.getPowerLevelByUserId(id);
|
||||
|
@ -89,9 +92,13 @@ class User extends Event {
|
|||
}, orElse: () => Membership.join);
|
||||
|
||||
/// The avatar if the user has one.
|
||||
Uri get avatarUrl => content != null && content['avatar_url'] is String
|
||||
? Uri.parse(content['avatar_url'])
|
||||
: null;
|
||||
Uri get avatarUrl => content != null && content.containsKey('avatar_url')
|
||||
? (content['avatar_url'] is String
|
||||
? Uri.parse(content['avatar_url'])
|
||||
: null)
|
||||
: (prevContent != null && prevContent['avatar_url'] is String
|
||||
? Uri.parse(prevContent['avatar_url'])
|
||||
: null);
|
||||
|
||||
/// Returns the displayname or the local part of the Matrix ID if the user
|
||||
/// has no displayname. If [formatLocalpart] is true, then the localpart will
|
||||
|
|
37
pubspec.lock
37
pubspec.lock
|
@ -22,13 +22,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.2"
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: archive
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.13"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -323,6 +316,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.6"
|
||||
matrix_file_e2ee:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: matrix_file_e2ee
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -331,7 +331,7 @@ packages:
|
|||
source: hosted
|
||||
version: "1.1.8"
|
||||
mime:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: mime
|
||||
url: "https://pub.dartlang.org"
|
||||
|
@ -386,6 +386,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.4.8"
|
||||
olm:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: olm
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -414,13 +421,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: petitparser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
pointycastle:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -652,13 +652,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.5.4"
|
||||
xml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xml
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.7.0"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
Loading…
Reference in a new issue