From fb25b3729df50651df6aeb77d8ab0c9b4cef77eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 29 Jul 2022 16:25:28 +0200 Subject: [PATCH] Peek into world-readable rooms from spotlight (#9115) --- cypress/e2e/12-spotlight/spotlight.spec.ts | 2 +- .../views/dialogs/spotlight/SpotlightDialog.tsx | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/12-spotlight/spotlight.spec.ts b/cypress/e2e/12-spotlight/spotlight.spec.ts index a99bb43f6a..d81cbc939b 100644 --- a/cypress/e2e/12-spotlight/spotlight.spec.ts +++ b/cypress/e2e/12-spotlight/spotlight.spec.ts @@ -246,7 +246,7 @@ describe("Spotlight", () => { cy.spotlightResults().eq(0).click(); cy.url().should("contain", room2Id); }).then(() => { - cy.get(".mx_RoomPreviewBar_actions .mx_AccessibleButton").click(); + cy.get(".mx_RoomView_MessageList").should("have.length", 1); cy.roomHeaderName().should("contain", room2Name); }); }); diff --git a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx index 4eed99fd56..87d39c981d 100644 --- a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx +++ b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx @@ -485,7 +485,11 @@ const SpotlightDialog: React.FC = ({ initialText = "", initialFilter = n // eslint-disable-next-line }, [results, filter]); - const viewRoom = (room: {roomId: string, roomAlias?: string}, persist = false, viaKeyboard = false) => { + const viewRoom = ( + room: { roomId: string, roomAlias?: string, autoJoin?: boolean, shouldPeek?: boolean}, + persist = false, + viaKeyboard = false, + ) => { if (persist) { const recents = new Set(SettingsStore.getValue("SpotlightSearch.recentSearches", null).reverse()); // remove & add the room to put it at the end @@ -506,6 +510,8 @@ const SpotlightDialog: React.FC = ({ initialText = "", initialFilter = n metricsViaKeyboard: viaKeyboard, room_id: room.roomId, room_alias: room.roomAlias, + auto_join: room.autoJoin, + should_peek: room.shouldPeek, }); onFinished(); }; @@ -623,6 +629,8 @@ const SpotlightDialog: React.FC = ({ initialText = "", initialFilter = n viewRoom({ roomAlias: publicRoom.canonical_alias || publicRoom.aliases?.[0], roomId: publicRoom.room_id, + autoJoin: !result.publicRoom.world_readable && !cli.isGuest(), + shouldPeek: result.publicRoom.world_readable || cli.isGuest(), }, true, ev.type !== "click"); }; return (