From 1e65dcd0aa974f439b20a2502d2d63ebfb9466ce Mon Sep 17 00:00:00 2001 From: Arne Wilken Date: Tue, 1 Nov 2022 21:56:40 +0100 Subject: [PATCH] Change ListNotificationState to store room ids (#9518) * Changed ListNotificationState to store room ids ListNotificationState stores a reference to a rooms array which is later used for comparing the stored array with new arrays. However, the comparison may fail since the stored array can be changed outside the class. This PR proposes to instead store only the room ids, which hopefully allows to avoid the issue by copying the room ids into a new array, while still being performant. Signed-off-by: Arne Wilken arnepokemon@yahoo.de * Change ListNotificationState to shallow clone rooms Instead of using room ids like in the previous commit, shallow clone the rooms array instead. Signed-off-by: Arne Wilken arnepokemon@yahoo.de Co-authored-by: Robin --- src/stores/notifications/ListNotificationState.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/notifications/ListNotificationState.ts b/src/stores/notifications/ListNotificationState.ts index 56af3be178..8ff1824bd6 100644 --- a/src/stores/notifications/ListNotificationState.ts +++ b/src/stores/notifications/ListNotificationState.ts @@ -45,7 +45,7 @@ export class ListNotificationState extends NotificationState { const oldRooms = this.rooms; const diff = arrayDiff(oldRooms, rooms); - this.rooms = rooms; + this.rooms = [...rooms]; for (const oldRoom of diff.removed) { const state = this.states[oldRoom.roomId]; if (!state) continue; // We likely just didn't have a badge (race condition)