diff --git a/lib/src/RoomList.dart b/lib/src/RoomList.dart index d24a424..6f439d5 100644 --- a/lib/src/RoomList.dart +++ b/lib/src/RoomList.dart @@ -68,6 +68,7 @@ class RoomList { this.onlyGroups = false}) { eventSub ??= client.connection.onEvent.stream.listen(_handleEventUpdate); roomSub ??= client.connection.onRoomUpdate.stream.listen(_handleRoomUpdate); + sort(); } Room getRoomByAlias(String alias) { @@ -148,9 +149,13 @@ class RoomList { sortAndUpdate(); } - sortAndUpdate() { + sort() { rooms?.sort((a, b) => b.timeCreated.toTimeStamp().compareTo(a.timeCreated.toTimeStamp())); + } + + sortAndUpdate() { + sort(); if (onUpdate != null) onUpdate(); } }