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();
|
sortAndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool sortLock = false;
|
||||||
|
|
||||||
sort() {
|
sort() {
|
||||||
|
if (sortLock) return;
|
||||||
|
sortLock = true;
|
||||||
rooms?.sort((a, b) =>
|
rooms?.sort((a, b) =>
|
||||||
b.timeCreated.toTimeStamp().compareTo(a.timeCreated.toTimeStamp()));
|
b.timeCreated.toTimeStamp().compareTo(a.timeCreated.toTimeStamp()));
|
||||||
|
sortLock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sortAndUpdate() {
|
sortAndUpdate() {
|
||||||
|
|
|
@ -119,9 +119,18 @@ class Timeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sortAndUpdate() {
|
bool sortLock = false;
|
||||||
|
|
||||||
|
sort() {
|
||||||
|
if (sortLock) return;
|
||||||
|
sortLock = true;
|
||||||
events
|
events
|
||||||
?.sort((a, b) => b.time.toTimeStamp().compareTo(a.time.toTimeStamp()));
|
?.sort((a, b) => b.time.toTimeStamp().compareTo(a.time.toTimeStamp()));
|
||||||
|
sortLock = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sortAndUpdate() {
|
||||||
|
sort();
|
||||||
if (onUpdate != null) onUpdate();
|
if (onUpdate != null) onUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue