Merge pull request #1749 from famedly/krille/sort-archive

chore: Sort archive by last activity
This commit is contained in:
Krille-chan 2024-03-28 09:01:33 +01:00 committed by GitHub
commit 29d982b2de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 0 deletions

View File

@ -1037,6 +1037,15 @@ class Client extends MatrixApi {
await _storeArchivedRoom(entry.key, entry.value);
}
}
// Sort the archived rooms by last event originServerTs as this is the
// best indicator we have to sort them. For archived rooms where we don't
// have any, we move them to the bottom.
final beginningOfTime = DateTime.fromMillisecondsSinceEpoch(0);
_archivedRooms.sort((b, a) =>
(a.room.lastEvent?.originServerTs ?? beginningOfTime)
.compareTo(b.room.lastEvent?.originServerTs ?? beginningOfTime));
return _archivedRooms;
}