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.roomId = roomId ?? room?.id;
|
||||||
this.senderId = senderId;
|
this.senderId = senderId;
|
||||||
this.unsigned = unsigned;
|
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.stateKey = stateKey;
|
||||||
this.originServerTs = originServerTs;
|
this.originServerTs = originServerTs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,10 @@ class User extends Event {
|
||||||
String get id => stateKey;
|
String get id => stateKey;
|
||||||
|
|
||||||
/// The displayname of the user if the user has set one.
|
/// 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.
|
/// Returns the power level of this user.
|
||||||
int get powerLevel => room?.getPowerLevelByUserId(id);
|
int get powerLevel => room?.getPowerLevelByUserId(id);
|
||||||
|
@ -89,9 +92,13 @@ class User extends Event {
|
||||||
}, orElse: () => Membership.join);
|
}, orElse: () => Membership.join);
|
||||||
|
|
||||||
/// The avatar if the user has one.
|
/// The avatar if the user has one.
|
||||||
Uri get avatarUrl => content != null && content['avatar_url'] is String
|
Uri get avatarUrl => content != null && content.containsKey('avatar_url')
|
||||||
? Uri.parse(content['avatar_url'])
|
? (content['avatar_url'] is String
|
||||||
: null;
|
? 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
|
/// 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
|
/// 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"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.2"
|
version: "0.2.2"
|
||||||
archive:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: archive
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.13"
|
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -323,6 +316,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.6"
|
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:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -331,7 +331,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.8"
|
version: "1.1.8"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: mime
|
name: mime
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
|
@ -386,6 +386,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.8"
|
version: "1.4.8"
|
||||||
|
olm:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: olm
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.2.1"
|
||||||
package_config:
|
package_config:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -414,13 +421,6 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.0"
|
version: "1.9.0"
|
||||||
petitparser:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: petitparser
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.2"
|
|
||||||
pointycastle:
|
pointycastle:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -652,13 +652,6 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.4"
|
version: "0.5.4"
|
||||||
xml:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: xml
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "3.7.0"
|
|
||||||
yaml:
|
yaml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
Loading…
Reference in a new issue