[RoomList] Get user and Statekey

This commit is contained in:
Christian Pauly 2019-07-29 09:44:55 +02:00
parent 29c677e5ba
commit c94246195f

View file

@ -114,7 +114,7 @@ class RoomList {
sortAndUpdate(); sortAndUpdate();
} }
void _handleEventUpdate(EventUpdate eventUpdate) { void _handleEventUpdate(EventUpdate eventUpdate) async {
// Is the event necessary for the chat list? If not, then return // Is the event necessary for the chat list? If not, then return
if (!(eventUpdate.type == "timeline" || if (!(eventUpdate.type == "timeline" ||
eventUpdate.eventType == "m.room.avatar" || eventUpdate.eventType == "m.room.avatar" ||
@ -134,12 +134,21 @@ class RoomList {
rooms[j].timeCreated) return;*/ rooms[j].timeCreated) return;*/
if (eventUpdate.type == "timeline") { if (eventUpdate.type == "timeline") {
User user = await client?.store?.getUser(
matrixID: eventUpdate.content["sender"],
room: Room(id: eventUpdate.roomID, client: client));
User stateKey = null;
if (eventUpdate.content.containsKey("state_key"))
stateKey = await client?.store?.getUser(
matrixID: eventUpdate.content["state_key"],
room: Room(id: eventUpdate.roomID, client: client));
// Update the last message preview // Update the last message preview
rooms[j].lastEvent = Event( rooms[j].lastEvent = Event(
eventUpdate.content["id"], eventUpdate.content["id"],
User(eventUpdate.content["sender"]), user ?? User(eventUpdate.content["sender"]),
ChatTime(eventUpdate.content["origin_server_ts"]), ChatTime(eventUpdate.content["origin_server_ts"]),
room: rooms[j], room: rooms[j],
stateKey: stateKey,
content: eventUpdate.content["content"], content: eventUpdate.content["content"],
environment: eventUpdate.eventType, environment: eventUpdate.eventType,
status: 2, status: 2,