diff --git a/lib/src/Connection.dart b/lib/src/Connection.dart index 074c3c4..9a9951b 100644 --- a/lib/src/Connection.dart +++ b/lib/src/Connection.dart @@ -462,7 +462,7 @@ class Connection { } } - if (userTimestampMap[mxid]["ts"] is int) { + if (userTimestampMap[mxid].containsKey("ts")) { if (receiptStateContent[eventID] == null) receiptStateContent[eventID] = {"m.read": {}}; else if (receiptStateContent[eventID]["m.read"] == null) diff --git a/lib/src/RoomList.dart b/lib/src/RoomList.dart index 5ea3d51..a3ffdeb 100644 --- a/lib/src/RoomList.dart +++ b/lib/src/RoomList.dart @@ -180,7 +180,7 @@ class RoomList { bool sortLock = false; sort() { - if (sortLock) return; + if (sortLock || rooms.length < 2) return; sortLock = true; rooms?.sort((a, b) => b.timeCreated.toTimeStamp().compareTo(a.timeCreated.toTimeStamp())); diff --git a/lib/src/Timeline.dart b/lib/src/Timeline.dart index f64597a..ab0e16c 100644 --- a/lib/src/Timeline.dart +++ b/lib/src/Timeline.dart @@ -122,7 +122,7 @@ class Timeline { bool sortLock = false; sort() { - if (sortLock) return; + if (sortLock || events.length < 2) return; sortLock = true; events ?.sort((a, b) => b.time.toTimeStamp().compareTo(a.time.toTimeStamp()));