[Lists] Add sort lock

This commit is contained in:
Christian Pauly 2019-10-01 09:39:15 +00:00
parent b3d98d5406
commit 269bea7350
2 changed files with 15 additions and 1 deletions

View file

@ -166,9 +166,14 @@ class RoomList {
sortAndUpdate();
}
bool sortLock = false;
sort() {
if (sortLock) return;
sortLock = true;
rooms?.sort((a, b) =>
b.timeCreated.toTimeStamp().compareTo(a.timeCreated.toTimeStamp()));
sortLock = false;
}
sortAndUpdate() {

View file

@ -119,9 +119,18 @@ class Timeline {
}
}
sortAndUpdate() {
bool sortLock = false;
sort() {
if (sortLock) return;
sortLock = true;
events
?.sort((a, b) => b.time.toTimeStamp().compareTo(a.time.toTimeStamp()));
sortLock = false;
}
sortAndUpdate() {
sort();
if (onUpdate != null) onUpdate();
}
}