From 2615cd2727f7c1a8cc305a7367cbfb8db9c1acc4 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Mon, 18 May 2020 12:56:24 +0200 Subject: [PATCH] fix lastEvent --- lib/src/room.dart | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index ac10d49a..54481ec8 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -370,16 +370,15 @@ class Room { String notificationSettings; Event get lastEvent { - var lastTime = DateTime.fromMillisecondsSinceEpoch(0); + var lastSortOrder = -1e32; // this bound to be small enough var lastEvent = getState('m.room.message'); if (lastEvent == null) { states.forEach((final String key, final entry) { if (!entry.containsKey('')) return; final Event state = entry['']; - if (state.time != null && - state.time.millisecondsSinceEpoch > - lastTime.millisecondsSinceEpoch) { - lastTime = state.time; + if (state.sortOrder != null && + state.sortOrder > lastSortOrder) { + lastSortOrder = state.sortOrder; lastEvent = state; } });