Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 6819b3a

Browse files
authored
Merge branch 'develop' into andybalaam/dynamic-predecessor-in-addexistingtospacedialog
2 parents 0e80423 + 421c1b9 commit 6819b3a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/utils/leave-behaviour.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import LeaveSpaceDialog from "../components/views/dialogs/LeaveSpaceDialog";
3535
import { AfterLeaveRoomPayload } from "../dispatcher/payloads/AfterLeaveRoomPayload";
3636
import { bulkSpaceBehaviour } from "./space";
3737
import { SdkContextClass } from "../contexts/SDKContext";
38+
import SettingsStore from "../settings/SettingsStore";
3839

3940
export async function leaveRoomBehaviour(roomId: string, retry = true, spinner = true): Promise<void> {
4041
let spinnerModal: IHandle<any> | undefined;
@@ -44,7 +45,11 @@ export async function leaveRoomBehaviour(roomId: string, retry = true, spinner =
4445

4546
const cli = MatrixClientPeg.get();
4647
let leavingAllVersions = true;
47-
const history = cli.getRoomUpgradeHistory(roomId);
48+
const history = cli.getRoomUpgradeHistory(
49+
roomId,
50+
false,
51+
SettingsStore.getValue("feature_dynamic_room_predecessors"),
52+
);
4853
if (history && history.length > 0) {
4954
const currentRoom = history[history.length - 1];
5055
if (currentRoom.roomId !== roomId) {

test/utils/leave-behaviour-test.ts

+26
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import DMRoomMap from "../../src/utils/DMRoomMap";
2929
import SpaceStore from "../../src/stores/spaces/SpaceStore";
3030
import { MetaSpace } from "../../src/stores/spaces";
3131
import { ActionPayload } from "../../src/dispatcher/payloads";
32+
import SettingsStore from "../../src/settings/SettingsStore";
3233

3334
describe("leaveRoomBehaviour", () => {
3435
SdkContextClass.instance.constructEagerStores(); // Initialize RoomViewStore
@@ -128,4 +129,29 @@ describe("leaveRoomBehaviour", () => {
128129
metricsTrigger: undefined,
129130
});
130131
});
132+
133+
describe("If the feature_dynamic_room_predecessors is not enabled", () => {
134+
beforeEach(() => {
135+
jest.spyOn(SettingsStore, "getValue").mockReturnValue(false);
136+
});
137+
138+
it("Passes through the dynamic predecessor setting", async () => {
139+
await leaveRoomBehaviour(room.roomId);
140+
expect(client.getRoomUpgradeHistory).toHaveBeenCalledWith(room.roomId, false, false);
141+
});
142+
});
143+
144+
describe("If the feature_dynamic_room_predecessors is enabled", () => {
145+
beforeEach(() => {
146+
// Turn on feature_dynamic_room_predecessors setting
147+
jest.spyOn(SettingsStore, "getValue").mockImplementation(
148+
(settingName) => settingName === "feature_dynamic_room_predecessors",
149+
);
150+
});
151+
152+
it("Passes through the dynamic predecessor setting", async () => {
153+
await leaveRoomBehaviour(room.roomId);
154+
expect(client.getRoomUpgradeHistory).toHaveBeenCalledWith(room.roomId, false, true);
155+
});
156+
});
131157
});

0 commit comments

Comments
 (0)