make equality stable in comparator for reaction

This commit is contained in:
Bruno Windels 2021-06-11 11:04:48 +02:00
parent 1d9709d4e3
commit 81a721f880

View file

@ -129,6 +129,12 @@ class ReactionViewModel {
} }
_compare(other) { _compare(other) {
// the comparator is also used to test for equality, if the comparison returns 0
// given that the firstTimestamp isn't set anymore when the last reaction is removed,
// the remove event wouldn't be able to find the correct index anymore. So special case equality.
if (other === this) {
return 0;
}
if (this.count !== other.count) { if (this.count !== other.count) {
return other.count - this.count; return other.count - this.count;
} else { } else {