[RoomList] Autosort
This commit is contained in:
parent
c5664bfa71
commit
ae573850bd
|
@ -68,6 +68,7 @@ class RoomList {
|
||||||
this.onlyGroups = false}) {
|
this.onlyGroups = false}) {
|
||||||
eventSub ??= client.connection.onEvent.stream.listen(_handleEventUpdate);
|
eventSub ??= client.connection.onEvent.stream.listen(_handleEventUpdate);
|
||||||
roomSub ??= client.connection.onRoomUpdate.stream.listen(_handleRoomUpdate);
|
roomSub ??= client.connection.onRoomUpdate.stream.listen(_handleRoomUpdate);
|
||||||
|
sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
Room getRoomByAlias(String alias) {
|
Room getRoomByAlias(String alias) {
|
||||||
|
@ -148,9 +149,13 @@ class RoomList {
|
||||||
sortAndUpdate();
|
sortAndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
sortAndUpdate() {
|
sort() {
|
||||||
rooms?.sort((a, b) =>
|
rooms?.sort((a, b) =>
|
||||||
b.timeCreated.toTimeStamp().compareTo(a.timeCreated.toTimeStamp()));
|
b.timeCreated.toTimeStamp().compareTo(a.timeCreated.toTimeStamp()));
|
||||||
|
}
|
||||||
|
|
||||||
|
sortAndUpdate() {
|
||||||
|
sort();
|
||||||
if (onUpdate != null) onUpdate();
|
if (onUpdate != null) onUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue