From 57aa045195d32103d03f81212e46256563e4d9d4 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 2 Sep 2021 14:27:20 -0600 Subject: [PATCH] Don't rely on rooms having timelines to use when checking widgets --- src/stores/widgets/StopGapWidget.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stores/widgets/StopGapWidget.ts b/src/stores/widgets/StopGapWidget.ts index d3c886d4b8..0013c77e1c 100644 --- a/src/stores/widgets/StopGapWidget.ts +++ b/src/stores/widgets/StopGapWidget.ts @@ -301,7 +301,9 @@ export class StopGapWidget extends EventEmitter { // requests timeline capabilities in other rooms down the road. It's just easier to manage here. for (const room of MatrixClientPeg.get().getRooms()) { // Timelines are most recent last - this.readUpToMap[room.roomId] = arrayFastClone(room.getLiveTimeline().getEvents()).reverse()[0].getId(); + const roomEvent = arrayFastClone(room.getLiveTimeline()?.getEvents() || []).reverse()[0]; + if (!roomEvent) continue; // force later code to think the room is fresh + this.readUpToMap[room.roomId] = roomEvent.getId(); } // Attach listeners for feeding events - the underlying widget classes handle permissions for us