Merge branch 'fix_app_88' into 'master'
Allow Events to have less async data See merge request famedly/famedlysdk!30
This commit is contained in:
commit
3a01b2520e
|
@ -50,6 +50,8 @@ class Event {
|
|||
/// The type of this event. Mostly this is 'timeline'.
|
||||
final String environment;
|
||||
|
||||
Event replyEvent;
|
||||
|
||||
/// The status of this event.
|
||||
/// -1=ERROR
|
||||
/// 0=SENDING
|
||||
|
@ -69,6 +71,7 @@ class Event {
|
|||
this.status = 2,
|
||||
this.environment,
|
||||
this.content,
|
||||
this.replyEvent,
|
||||
});
|
||||
|
||||
/// Returns the body of this event if it has a body.
|
||||
|
|
|
@ -80,14 +80,41 @@ class Timeline {
|
|||
events[i] = Event.fromJson(eventUpdate.content, room);
|
||||
}
|
||||
} else {
|
||||
User user = await room.client.store
|
||||
Event newEvent;
|
||||
User senderUser = await room.client.store
|
||||
?.getUser(matrixID: eventUpdate.content["sender"], room: room);
|
||||
if (user != null) {
|
||||
eventUpdate.content["displayname"] = user.displayName;
|
||||
eventUpdate.content["avatar_url"] = user.avatarUrl.mxc;
|
||||
if (senderUser != null) {
|
||||
eventUpdate.content["displayname"] = senderUser.displayName;
|
||||
eventUpdate.content["avatar_url"] = senderUser.avatarUrl.mxc;
|
||||
}
|
||||
|
||||
Event newEvent = Event.fromJson(eventUpdate.content, room);
|
||||
User stateKeyUser;
|
||||
if (eventUpdate.content.containsKey("state_key")) {
|
||||
stateKeyUser = await room.client.store?.getUser(
|
||||
matrixID: eventUpdate.content["state_key"], room: room);
|
||||
}
|
||||
|
||||
if (senderUser != null && stateKeyUser != null) {
|
||||
newEvent = Event.fromJson(eventUpdate.content, room,
|
||||
senderUser: senderUser, stateKeyUser: stateKeyUser);
|
||||
} else if (senderUser != null) {
|
||||
newEvent = Event.fromJson(eventUpdate.content, room,
|
||||
senderUser: senderUser);
|
||||
} else if (stateKeyUser != null) {
|
||||
newEvent = Event.fromJson(eventUpdate.content, room,
|
||||
stateKeyUser: stateKeyUser);
|
||||
} else {
|
||||
newEvent = Event.fromJson(eventUpdate.content, room);
|
||||
}
|
||||
|
||||
// TODO update to type check when https://gitlab.com/famedly/famedlysdk/merge_requests/28/ is merged
|
||||
if (newEvent.content.containsKey("m.relates_to")) {
|
||||
Map<String, dynamic> relates_to = newEvent.content["m.relates_to"];
|
||||
if (relates_to.containsKey("m.in_reply_to")) {
|
||||
newEvent.replyEvent = await room.getEventById(newEvent
|
||||
.content["m.relates_to"]["m.in_reply_to"]["event_id"]);
|
||||
}
|
||||
}
|
||||
|
||||
events.insert(0, newEvent);
|
||||
if (onInsert != null) onInsert(0);
|
||||
|
|
10
pubspec.lock
10
pubspec.lock
|
@ -1,5 +1,5 @@
|
|||
# Generated by pub
|
||||
# See https://www.dartlang.org/tools/pub/glossary#lockfile
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
|
@ -21,7 +21,7 @@ packages:
|
|||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.2.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -297,7 +297,7 @@ packages:
|
|||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
version: "1.7.0"
|
||||
pool:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -325,7 +325,7 @@ packages:
|
|||
name: quiver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
version: "2.0.3"
|
||||
shelf:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -414,7 +414,7 @@ packages:
|
|||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.4"
|
||||
version: "0.2.5"
|
||||
timing:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
Loading…
Reference in a new issue