Merge branch 'krille/fix-room-sorting' into 'master'
Fix room sorting See merge request famedly/famedlysdk!389
This commit is contained in:
commit
f4c8cfe992
|
@ -87,7 +87,8 @@ class Client {
|
||||||
this.enableE2eeRecovery = false,
|
this.enableE2eeRecovery = false,
|
||||||
this.verificationMethods,
|
this.verificationMethods,
|
||||||
http.Client httpClient,
|
http.Client httpClient,
|
||||||
this.importantStateEvents}) {
|
this.importantStateEvents,
|
||||||
|
this.pinUnreadRooms = false}) {
|
||||||
verificationMethods ??= <KeyVerificationMethod>{};
|
verificationMethods ??= <KeyVerificationMethod>{};
|
||||||
importantStateEvents ??= <String>{};
|
importantStateEvents ??= <String>{};
|
||||||
importantStateEvents.addAll([
|
importantStateEvents.addAll([
|
||||||
|
@ -1101,13 +1102,16 @@ class Client {
|
||||||
|
|
||||||
bool _sortLock = false;
|
bool _sortLock = false;
|
||||||
|
|
||||||
|
/// If [true] then unread rooms are pinned at the top of the room list.
|
||||||
|
bool pinUnreadRooms;
|
||||||
|
|
||||||
/// The compare function how the rooms should be sorted internally. By default
|
/// The compare function how the rooms should be sorted internally. By default
|
||||||
/// rooms are sorted by timestamp of the last m.room.message event or the last
|
/// rooms are sorted by timestamp of the last m.room.message event or the last
|
||||||
/// event if there is no known message.
|
/// event if there is no known message.
|
||||||
RoomSorter sortRoomsBy = (a, b) => (a.membership != b.membership)
|
RoomSorter get sortRoomsBy => (a, b) => (a.isFavourite != b.isFavourite)
|
||||||
? (a.membership == Membership.invite ? -1 : 1)
|
? (a.isFavourite ? -1 : 1)
|
||||||
: (a.isFavourite != b.isFavourite)
|
: (pinUnreadRooms && a.notificationCount != b.notificationCount)
|
||||||
? (a.isFavourite ? -1 : 1)
|
? b.notificationCount.compareTo(a.notificationCount)
|
||||||
: b.timeCreated.millisecondsSinceEpoch
|
: b.timeCreated.millisecondsSinceEpoch
|
||||||
.compareTo(a.timeCreated.millisecondsSinceEpoch);
|
.compareTo(a.timeCreated.millisecondsSinceEpoch);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue