From 07d5b4139db1f7f51262e2331255b04a65230153 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 17 Feb 2022 15:40:12 +0000 Subject: [PATCH] Add way to join room address via new search dialog (#7830) --- res/css/views/dialogs/_SpotlightDialog.scss | 5 +++ .../views/dialogs/SpotlightDialog.tsx | 32 +++++++++++++++++++ src/i18n/strings/en_EN.json | 1 + 3 files changed, 38 insertions(+) diff --git a/res/css/views/dialogs/_SpotlightDialog.scss b/res/css/views/dialogs/_SpotlightDialog.scss index dd752ecdef..62df1b143c 100644 --- a/res/css/views/dialogs/_SpotlightDialog.scss +++ b/res/css/views/dialogs/_SpotlightDialog.scss @@ -174,6 +174,7 @@ limitations under the License. .mx_SpotlightDialog_otherSearches { .mx_SpotlightDialog_startChat, + .mx_SpotlightDialog_joinRoomAlias, .mx_SpotlightDialog_explorePublicRooms { padding-left: 32px; position: relative; @@ -197,6 +198,10 @@ limitations under the License. mask-image: url('$(res)/img/element-icons/room/members.svg'); } + .mx_SpotlightDialog_joinRoomAlias::before { + mask-image: url('$(res)/img/element-icons/roomlist/hash-circle.svg'); + } + .mx_SpotlightDialog_explorePublicRooms::before { mask-image: url('$(res)/img/element-icons/roomlist/explore.svg'); } diff --git a/src/components/views/dialogs/SpotlightDialog.tsx b/src/components/views/dialogs/SpotlightDialog.tsx index 08cbdf4397..4c0bf1da1d 100644 --- a/src/components/views/dialogs/SpotlightDialog.tsx +++ b/src/components/views/dialogs/SpotlightDialog.tsx @@ -72,6 +72,7 @@ import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload"; import { getMetaSpaceName } from "../../../stores/spaces"; import { getKeyBindingsManager } from "../../../KeyBindingsManager"; import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts"; +import { getCachedRoomIDForAlias } from "../../../RoomAliasCache"; const MAX_RECENT_SEARCHES = 10; const SECTION_LIMIT = 50; // only show 50 results per section for performance reasons @@ -413,11 +414,42 @@ const SpotlightDialog: React.FC = ({ initialText = "", onFinished }) => ; } + let joinRoomSection: JSX.Element; + if (trimmedQuery.startsWith("#") && + trimmedQuery.includes(":") && + (!getCachedRoomIDForAlias(trimmedQuery) || !cli.getRoom(getCachedRoomIDForAlias(trimmedQuery))) + ) { + joinRoomSection =
+
+ +
+
; + } + content = <> { peopleSection } { roomsSection } { spacesSection } { spaceRoomsSection } + { joinRoomSection }

{ _t('Use "%(query)s" to search', { query }) }

diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 357982a09c..997bebff28 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2794,6 +2794,7 @@ "Settings - %(spaceName)s": "Settings - %(spaceName)s", "Spaces you're in": "Spaces you're in", "Other rooms in %(spaceName)s": "Other rooms in %(spaceName)s", + "Join %(roomAddress)s": "Join %(roomAddress)s", "Use \"%(query)s\" to search": "Use \"%(query)s\" to search", "Public rooms": "Public rooms", "Other searches": "Other searches",