diff --git a/src/stores/widgets/StopGapWidgetDriver.ts b/src/stores/widgets/StopGapWidgetDriver.ts index 38b304bbdebe..9fbf5e4c5648 100644 --- a/src/stores/widgets/StopGapWidgetDriver.ts +++ b/src/stores/widgets/StopGapWidgetDriver.ts @@ -380,13 +380,10 @@ export class StopGapWidgetDriver extends WidgetDriver { direction?: 'f' | 'b', ): Promise { const client = MatrixClientPeg.get(); - const dir = - direction && Object.values(Direction as Record).includes(direction) - ? direction as Direction - : undefined; - const room = roomId !== undefined ? roomId : RoomViewStore.instance.getRoomId(); + const dir = direction as Direction; + roomId = roomId ?? RoomViewStore.instance.getRoomId() ?? undefined; - if (typeof room !== "string") { + if (typeof roomId !== "string") { throw new Error('Error while reading the current room'); } @@ -396,7 +393,7 @@ export class StopGapWidgetDriver extends WidgetDriver { nextBatch, prevBatch, } = await client.relations( - room, + roomId, eventId, relationType ?? null, eventType ?? null,