From 93b4efe004efb1a5aab3b31b72ccd2ad16fed032 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Thu, 29 Aug 2019 09:50:04 +0200 Subject: [PATCH] [Room] LastEvent calculation fix --- lib/src/Room.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/src/Room.dart b/lib/src/Room.dart index 8ac8569..0fa3e29 100644 --- a/lib/src/Room.dart +++ b/lib/src/Room.dart @@ -124,7 +124,14 @@ class Room { /// Must be one of [all, mention] String notificationSettings; - Event get lastEvent => states["m.room.message"]?.timelineEvent; + Event get lastEvent { + ChatTime lastTime = ChatTime(0); + Event lastEvent = null; + states.forEach((String key, RoomState value) { + if (value.time > lastTime) lastEvent = value.timelineEvent; + }); + return lastEvent; + } /// Your current client instance. final Client client;