From c94246195fc7aa3938e00f61b05fe56019b13c15 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 29 Jul 2019 09:44:55 +0200 Subject: [PATCH] [RoomList] Get user and Statekey --- lib/src/RoomList.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/src/RoomList.dart b/lib/src/RoomList.dart index a777fcb..9b78784 100644 --- a/lib/src/RoomList.dart +++ b/lib/src/RoomList.dart @@ -114,7 +114,7 @@ class RoomList { sortAndUpdate(); } - void _handleEventUpdate(EventUpdate eventUpdate) { + void _handleEventUpdate(EventUpdate eventUpdate) async { // Is the event necessary for the chat list? If not, then return if (!(eventUpdate.type == "timeline" || eventUpdate.eventType == "m.room.avatar" || @@ -134,12 +134,21 @@ class RoomList { rooms[j].timeCreated) return;*/ 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 rooms[j].lastEvent = Event( eventUpdate.content["id"], - User(eventUpdate.content["sender"]), + user ?? User(eventUpdate.content["sender"]), ChatTime(eventUpdate.content["origin_server_ts"]), room: rooms[j], + stateKey: stateKey, content: eventUpdate.content["content"], environment: eventUpdate.eventType, status: 2,