chore: Sort archive by last activity

This commit is contained in:
Krille 2024-03-26 13:30:06 +01:00
parent 90ab339277
commit 0e867402bc
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
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;
}