From af476905b69c8434fedce1116fab6bfb50d83ecc Mon Sep 17 00:00:00 2001 From: R Midhun Suresh Date: Mon, 10 Mar 2025 18:03:06 +0530 Subject: [PATCH] Room List Store: Fetch rooms after space store is ready + attach store to window (#29453) * Attach the new store to window * Fetch rooms after space store is ready If we fetch a list of rooms and then wait for the space store to be ready, we will need some way of handling the onAction calls we get while we wait. These calls are dropped now. --- src/@types/global.d.ts | 2 ++ src/stores/room-list-v3/RoomListStoreV3.ts | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index 1df84ad344..3bbeda067b 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -47,6 +47,7 @@ import { type DeepReadonly } from "./common"; import type MatrixChat from "../components/structures/MatrixChat"; import { type InitialCryptoSetupStore } from "../stores/InitialCryptoSetupStore"; import { type ModuleApiType } from "../modules/Api.ts"; +import type { RoomListStoreV3Class } from "../stores/room-list-v3/RoomListStoreV3.ts"; /* eslint-disable @typescript-eslint/naming-convention */ @@ -99,6 +100,7 @@ declare global { mxToastStore: ToastStore; mxDeviceListener: DeviceListener; mxRoomListStore: RoomListStore; + mxRoomListStoreV3: RoomListStoreV3Class; mxRoomListLayoutStore: RoomListLayoutStore; mxPlatformPeg: PlatformPeg; mxIntegrationManagers: typeof IntegrationManagers; diff --git a/src/stores/room-list-v3/RoomListStoreV3.ts b/src/stores/room-list-v3/RoomListStoreV3.ts index 21bbe3140d..8d1bf8331f 100644 --- a/src/stores/room-list-v3/RoomListStoreV3.ts +++ b/src/stores/room-list-v3/RoomListStoreV3.ts @@ -116,8 +116,8 @@ export class RoomListStoreV3Class extends AsyncStoreWithClient { if (this.roomSkipList?.initialized || !this.matrixClient) return; const sorter = new RecencySorter(this.matrixClient.getSafeUserId()); this.roomSkipList = new RoomSkipList(sorter, FILTERS); - const rooms = this.getRooms(); await SpaceStore.instance.storeReadyPromise; + const rooms = this.getRooms(); this.roomSkipList.seed(rooms); this.emit(LISTS_UPDATE_EVENT); } @@ -244,3 +244,5 @@ export default class RoomListStoreV3 { return this.internalInstance; } } + +window.mxRoomListStoreV3 = RoomListStoreV3.instance;