mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 09:46:09 +03:00
Fix joining public rooms without aliases in search dialog (#10437)
Co-authored-by: Andy Balaam <andy.balaam@matrix.org>
This commit is contained in:
parent
45525480ef
commit
1c039fcd38
2 changed files with 39 additions and 2 deletions
|
@ -492,7 +492,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
|||
}, [results, filter]);
|
||||
|
||||
const viewRoom = (
|
||||
room: { roomId: string; roomAlias?: string; autoJoin?: boolean; shouldPeek?: boolean },
|
||||
room: { roomId: string; roomAlias?: string; autoJoin?: boolean; shouldPeek?: boolean; viaServers?: string[] },
|
||||
persist = false,
|
||||
viaKeyboard = false,
|
||||
): void => {
|
||||
|
@ -518,6 +518,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
|||
room_alias: room.roomAlias,
|
||||
auto_join: room.autoJoin,
|
||||
should_peek: room.shouldPeek,
|
||||
via_servers: room.viaServers,
|
||||
});
|
||||
onFinished();
|
||||
};
|
||||
|
@ -634,6 +635,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
|||
roomId: publicRoom.room_id,
|
||||
autoJoin: !result.publicRoom.world_readable && !cli.isGuest(),
|
||||
shouldPeek: result.publicRoom.world_readable || cli.isGuest(),
|
||||
viaServers: [config.roomServer],
|
||||
},
|
||||
true,
|
||||
ev.type !== "click",
|
||||
|
|
|
@ -29,6 +29,8 @@ import { flushPromisesWithFakeTimers, mkRoom, stubClient } from "../../../test-u
|
|||
import { shouldShowFeedback } from "../../../../src/utils/Feedback";
|
||||
import SettingsStore from "../../../../src/settings/SettingsStore";
|
||||
import { SettingLevel } from "../../../../src/settings/SettingLevel";
|
||||
import defaultDispatcher from "../../../../src/dispatcher/dispatcher";
|
||||
import SdkConfig from "../../../../src/SdkConfig";
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
||||
|
@ -40,6 +42,11 @@ jest.mock("../../../../src/utils/direct-messages", () => ({
|
|||
startDmOnFirstMessage: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock("../../../../src/dispatcher/dispatcher", () => ({
|
||||
register: jest.fn(),
|
||||
dispatch: jest.fn(),
|
||||
}));
|
||||
|
||||
interface IUserChunkMember {
|
||||
user_id: string;
|
||||
display_name?: string;
|
||||
|
@ -122,7 +129,7 @@ describe("Spotlight Dialog", () => {
|
|||
};
|
||||
|
||||
const testPublicRoom: IPublicRoomsChunkRoom = {
|
||||
room_id: "@room247:matrix.org",
|
||||
room_id: "!room247:matrix.org",
|
||||
name: "Room #247",
|
||||
topic: "We hope you'll have a <b>shining</b> experience!",
|
||||
world_readable: false,
|
||||
|
@ -352,6 +359,34 @@ describe("Spotlight Dialog", () => {
|
|||
expect(startDmOnFirstMessage).toHaveBeenCalledWith(mockedClient, [new DirectoryMember(testPerson)]);
|
||||
});
|
||||
|
||||
it("should pass via of the server being explored when joining room from directory", async () => {
|
||||
SdkConfig.put({
|
||||
room_directory: {
|
||||
servers: ["example.tld"],
|
||||
},
|
||||
});
|
||||
localStorage.setItem("mx_last_room_directory_server", "example.tld");
|
||||
|
||||
render(<SpotlightDialog initialFilter={Filter.PublicRooms} onFinished={() => null} />);
|
||||
|
||||
jest.advanceTimersByTime(200);
|
||||
await flushPromisesWithFakeTimers();
|
||||
|
||||
const content = document.querySelector("#mx_SpotlightDialog_content")!;
|
||||
const options = content.querySelectorAll("div.mx_SpotlightDialog_option");
|
||||
expect(options.length).toBe(1);
|
||||
expect(options[0].innerHTML).toContain(testPublicRoom.name);
|
||||
|
||||
fireEvent.click(options[0]!);
|
||||
expect(defaultDispatcher.dispatch).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
action: "view_room",
|
||||
room_id: testPublicRoom.room_id,
|
||||
via_servers: ["example.tld"],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
describe("Feedback prompt", () => {
|
||||
it("should show feedback prompt if feedback is enabled", async () => {
|
||||
mocked(shouldShowFeedback).mockReturnValue(true);
|
||||
|
|
Loading…
Reference in a new issue