From 81a721f88025450cf5b6cd81fc3ac787a8e0c9d1 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 11 Jun 2021 11:04:48 +0200 Subject: [PATCH] make equality stable in comparator for reaction --- src/domain/session/room/timeline/ReactionsViewModel.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/domain/session/room/timeline/ReactionsViewModel.js b/src/domain/session/room/timeline/ReactionsViewModel.js index b7426b49..83757c13 100644 --- a/src/domain/session/room/timeline/ReactionsViewModel.js +++ b/src/domain/session/room/timeline/ReactionsViewModel.js @@ -129,6 +129,12 @@ class ReactionViewModel { } _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) { return other.count - this.count; } else {