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

Commit

Permalink
Support dynamic room predecessors in ForwardDialog (#10344)
Browse files Browse the repository at this point in the history
  • Loading branch information
andybalaam authored Mar 10, 2023
1 parent 42abfb1 commit 2e064e5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/views/dialogs/ForwardDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,16 @@ const ForwardDialog: React.FC<IProps> = ({ matrixClient: cli, event, permalinkCr
const lcQuery = query.toLowerCase();

const previewLayout = useSettingValue<Layout>("layout");
const msc3946DynamicRoomPredecessors = useSettingValue<boolean>("feature_dynamic_room_predecessors");

let rooms = useMemo(
() =>
sortRooms(cli.getVisibleRooms().filter((room) => room.getMyMembership() === "join" && !room.isSpaceRoom())),
[cli],
sortRooms(
cli
.getVisibleRooms(msc3946DynamicRoomPredecessors)
.filter((room) => room.getMyMembership() === "join" && !room.isSpaceRoom()),
),
[cli, msc3946DynamicRoomPredecessors],
);

if (lcQuery) {
Expand Down
28 changes: 28 additions & 0 deletions test/components/views/dialogs/ForwardDialog-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
mockPlatformPeg,
} from "../../../test-utils";
import { TILE_SERVER_WK_KEY } from "../../../../src/utils/WellKnownUtils";
import SettingsStore from "../../../../src/settings/SettingsStore";

describe("ForwardDialog", () => {
const sourceRoom = "!111111111111111111:example.org";
Expand Down Expand Up @@ -325,4 +326,31 @@ describe("ForwardDialog", () => {
);
});
});

describe("If the feature_dynamic_room_predecessors is not enabled", () => {
beforeEach(() => {
jest.spyOn(SettingsStore, "getValue").mockReturnValue(false);
});

it("Passes through the dynamic predecessor setting", async () => {
mockClient.getVisibleRooms.mockClear();
mountForwardDialog();
expect(mockClient.getVisibleRooms).toHaveBeenCalledWith(false);
});
});

describe("If the feature_dynamic_room_predecessors is enabled", () => {
beforeEach(() => {
// Turn on feature_dynamic_room_predecessors setting
jest.spyOn(SettingsStore, "getValue").mockImplementation(
(settingName) => settingName === "feature_dynamic_room_predecessors",
);
});

it("Passes through the dynamic predecessor setting", async () => {
mockClient.getVisibleRooms.mockClear();
mountForwardDialog();
expect(mockClient.getVisibleRooms).toHaveBeenCalledWith(true);
});
});
});

0 comments on commit 2e064e5

Please sign in to comment.