Merge branch 'lists-fix-concurrent-sorts' into 'master'
[Lists] Add sort lock See merge request famedly/famedlysdk!92
This commit is contained in:
commit
ea83718682
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue