From 7191c01265d4a9db87c92c6038d2d06aed3313df Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 18 Jun 2020 15:52:55 -0600 Subject: [PATCH] Fix crash when filtering new room list too fast Fixes https://github.com/vector-im/riot-web/issues/14092 We were simply assuming we had a reference to a notification state, which might not be the case if we're between renders. --- src/components/views/rooms/NotificationBadge.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/views/rooms/NotificationBadge.tsx b/src/components/views/rooms/NotificationBadge.tsx index af5a84ed92..b742f8e8e7 100644 --- a/src/components/views/rooms/NotificationBadge.tsx +++ b/src/components/views/rooms/NotificationBadge.tsx @@ -240,6 +240,7 @@ export class ListNotificationState extends EventEmitter implements IDestroyable 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) delete this.states[oldRoom.roomId]; state.off(NOTIFICATION_STATE_UPDATE, this.onRoomNotificationStateUpdate); state.destroy();