From 9fae0012c8c454d8cd1c3db4ebd6a5c67ffa4e16 Mon Sep 17 00:00:00 2001 From: R Midhun Suresh Date: Sun, 2 Mar 2025 18:16:43 +0530 Subject: [PATCH] Remove redundant code On a timeline action, we return early if payload.room is falsy. So then why do we need to retry fetching the room? I think this can be removed but will ask others if there's some conext I'm missing. --- src/stores/room-list-v3/RoomListStoreV3.ts | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/stores/room-list-v3/RoomListStoreV3.ts b/src/stores/room-list-v3/RoomListStoreV3.ts index de3502b7d8..5aad4712ef 100644 --- a/src/stores/room-list-v3/RoomListStoreV3.ts +++ b/src/stores/room-list-v3/RoomListStoreV3.ts @@ -138,18 +138,9 @@ export class RoomListStoreV3Class extends AsyncStoreWithClient { if (!payload.isLiveEvent || !payload.isLiveUnfilteredRoomTimelineEvent || !payload.room) return; const roomId = payload.event.getRoomId(); - const findAndAddRoom = (): boolean => { - const room = this.matrixClient?.getRoom(roomId); - if (room) this.addRoomAndEmit(room); - return !!room; - }; - // We'll try finding the room associated with this event. - // If we can't find the room, we'll try again after 100ms. - if (!findAndAddRoom()) { - logger.warn(`Live timeline event ${payload.event.getId()} received without associated room`); - logger.warn(`Queuing failed room update for retry as a result.`); - setTimeout(findAndAddRoom, 100); - } + const room = this.matrixClient?.getRoom(roomId); + if (room) this.addRoomAndEmit(room); + else logger.warn(`Live timeline event ${payload.event.getId()} received without associated room`); break; } @@ -165,7 +156,6 @@ export class RoomListStoreV3Class extends AsyncStoreWithClient { const prevRoom = this.matrixClient?.getRoom(predecessor.roomId); if (prevRoom) this.roomSkipList.removeRoom(prevRoom); else logger.warn(`Unable to find predecessor room with id ${predecessor.roomId}`); - } } this.addRoomAndEmit(payload.room);