Skip to content

Commit 5888dfd

Browse files
Return RLS instance through function to avoid import side effect (#31091)
* Attach function that returns instance So that just importing this file does not create a RLS instance. * Fix jest test
1 parent 09c3afd commit 5888dfd

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/@types/global.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ declare global {
9898
mxToastStore: ToastStore;
9999
mxDeviceListener: DeviceListener;
100100
mxRoomListStore: RoomListStore;
101-
mxRoomListStoreV3: RoomListStoreV3Class;
101+
getRoomListStoreV3: () => RoomListStoreV3Class;
102102
mxRoomListLayoutStore: RoomListLayoutStore;
103103
mxPlatformPeg: PlatformPeg;
104104
mxIntegrationManagers: typeof IntegrationManagers;

src/stores/room-list-v3/RoomListStoreV3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,4 +373,4 @@ export default class RoomListStoreV3 {
373373
}
374374
}
375375

376-
window.mxRoomListStoreV3 = RoomListStoreV3.instance;
376+
window.getRoomListStoreV3 = () => RoomListStoreV3.instance;

test/unit-tests/components/viewmodels/roomlist/RoomListHeaderViewModel-test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ describe("useRoomListHeaderViewModel", () => {
4848
beforeEach(() => {
4949
matrixClient = stubClient();
5050
space = mkStubRoom("spaceId", "spaceName", matrixClient);
51+
jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string): any => {
52+
if (name === "RoomList.preferredSorting") return SortingAlgorithm.Recency;
53+
});
5154
});
5255

5356
afterEach(() => {

0 commit comments

Comments
 (0)