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

Commit 2e064e5

Browse files
authored
Support dynamic room predecessors in ForwardDialog (#10344)
1 parent 42abfb1 commit 2e064e5

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/components/views/dialogs/ForwardDialog.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,16 @@ const ForwardDialog: React.FC<IProps> = ({ matrixClient: cli, event, permalinkCr
227227
const lcQuery = query.toLowerCase();
228228

229229
const previewLayout = useSettingValue<Layout>("layout");
230+
const msc3946DynamicRoomPredecessors = useSettingValue<boolean>("feature_dynamic_room_predecessors");
230231

231232
let rooms = useMemo(
232233
() =>
233-
sortRooms(cli.getVisibleRooms().filter((room) => room.getMyMembership() === "join" && !room.isSpaceRoom())),
234-
[cli],
234+
sortRooms(
235+
cli
236+
.getVisibleRooms(msc3946DynamicRoomPredecessors)
237+
.filter((room) => room.getMyMembership() === "join" && !room.isSpaceRoom()),
238+
),
239+
[cli, msc3946DynamicRoomPredecessors],
235240
);
236241

237242
if (lcQuery) {

test/components/views/dialogs/ForwardDialog-test.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
mockPlatformPeg,
3737
} from "../../../test-utils";
3838
import { TILE_SERVER_WK_KEY } from "../../../../src/utils/WellKnownUtils";
39+
import SettingsStore from "../../../../src/settings/SettingsStore";
3940

4041
describe("ForwardDialog", () => {
4142
const sourceRoom = "!111111111111111111:example.org";
@@ -325,4 +326,31 @@ describe("ForwardDialog", () => {
325326
);
326327
});
327328
});
329+
330+
describe("If the feature_dynamic_room_predecessors is not enabled", () => {
331+
beforeEach(() => {
332+
jest.spyOn(SettingsStore, "getValue").mockReturnValue(false);
333+
});
334+
335+
it("Passes through the dynamic predecessor setting", async () => {
336+
mockClient.getVisibleRooms.mockClear();
337+
mountForwardDialog();
338+
expect(mockClient.getVisibleRooms).toHaveBeenCalledWith(false);
339+
});
340+
});
341+
342+
describe("If the feature_dynamic_room_predecessors is enabled", () => {
343+
beforeEach(() => {
344+
// Turn on feature_dynamic_room_predecessors setting
345+
jest.spyOn(SettingsStore, "getValue").mockImplementation(
346+
(settingName) => settingName === "feature_dynamic_room_predecessors",
347+
);
348+
});
349+
350+
it("Passes through the dynamic predecessor setting", async () => {
351+
mockClient.getVisibleRooms.mockClear();
352+
mountForwardDialog();
353+
expect(mockClient.getVisibleRooms).toHaveBeenCalledWith(true);
354+
});
355+
});
328356
});

0 commit comments

Comments
 (0)