Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Change ListNotificationState to store room ids (#9518)
Browse files Browse the repository at this point in the history
* 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 <robin@robin.town>
  • Loading branch information
Arnei and robintown committed Nov 1, 2022
1 parent 89a1eac commit 1e65dcd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/stores/notifications/ListNotificationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1e65dcd

Please sign in to comment.