|
5 | 5 | * Please see LICENSE files in the repository root for full details.
|
6 | 6 | */
|
7 | 7 |
|
8 |
| -import React, { type JSX } from "react"; |
9 |
| -import { Button } from "@vector-im/compound-web"; |
10 |
| -import ExploreIcon from "@vector-im/compound-design-tokens/assets/web/icons/explore"; |
11 |
| -import SearchIcon from "@vector-im/compound-design-tokens/assets/web/icons/search"; |
12 |
| -import DialPadIcon from "@vector-im/compound-design-tokens/assets/web/icons/dial-pad"; |
| 8 | +import React, { type JSX, useMemo } from "react"; |
13 | 9 |
|
14 |
| -import { IS_MAC, Key } from "../../../../shared-components/Keyboard"; |
15 |
| -import { _t } from "../../../../languageHandler"; |
16 |
| -import { ALTERNATE_KEY_NAME } from "../../../../accessibility/KeyboardShortcuts"; |
17 |
| -import { shouldShowComponent } from "../../../../customisations/helpers/UIComponents"; |
18 |
| -import { UIComponent } from "../../../../settings/UIFeature"; |
19 |
| -import { MetaSpace } from "../../../../stores/spaces"; |
20 |
| -import { Action } from "../../../../dispatcher/actions"; |
21 |
| -import PosthogTrackers from "../../../../PosthogTrackers"; |
22 |
| -import defaultDispatcher from "../../../../dispatcher/dispatcher"; |
23 |
| -import { Flex } from "../../../../shared-components/Flex"; |
24 |
| -import { useTypedEventEmitterState } from "../../../../hooks/useEventEmitter"; |
25 |
| -import LegacyCallHandler, { LegacyCallHandlerEvent } from "../../../../LegacyCallHandler"; |
26 |
| - |
27 |
| -type RoomListSearchProps = { |
28 |
| - /** |
29 |
| - * Current active space |
30 |
| - * The explore button is only displayed in the Home meta space |
31 |
| - */ |
32 |
| - activeSpace: string; |
33 |
| -}; |
| 10 | +import { RoomListSearchViewModel } from "../../../../viewmodels/room-list/RoomListSearchViewModel"; |
| 11 | +import { RoomListSearch as RoomListSearchView } from "../../../../shared-components/room-list/RoomListSearch"; |
34 | 12 |
|
35 | 13 | /**
|
36 | 14 | * A search component to be displayed at the top of the room list
|
37 | 15 | * The `Explore` button is displayed only in the Home meta space and when UIComponent.ExploreRooms is enabled.
|
38 | 16 | */
|
39 |
| -export function RoomListSearch({ activeSpace }: RoomListSearchProps): JSX.Element { |
40 |
| - const displayExploreButton = activeSpace === MetaSpace.Home && shouldShowComponent(UIComponent.ExploreRooms); |
41 |
| - // We only display the dial button if the user is can make PSTN calls |
42 |
| - const displayDialButton = useTypedEventEmitterState( |
43 |
| - LegacyCallHandler.instance, |
44 |
| - LegacyCallHandlerEvent.ProtocolSupport, |
45 |
| - () => LegacyCallHandler.instance.getSupportsPstnProtocol(), |
46 |
| - ); |
47 |
| - |
48 |
| - return ( |
49 |
| - <Flex className="mx_RoomListSearch" role="search" gap="var(--cpd-space-2x)" align="center"> |
50 |
| - <Button |
51 |
| - className="mx_RoomListSearch_search" |
52 |
| - kind="secondary" |
53 |
| - size="sm" |
54 |
| - Icon={SearchIcon} |
55 |
| - onClick={() => defaultDispatcher.fire(Action.OpenSpotlight)} |
56 |
| - > |
57 |
| - <Flex as="span" justify="space-between"> |
58 |
| - <span className="mx_RoomListSearch_search_text">{_t("action|search")}</span> |
59 |
| - <kbd>{IS_MAC ? "⌘ K" : _t(ALTERNATE_KEY_NAME[Key.CONTROL]) + " K"}</kbd> |
60 |
| - </Flex> |
61 |
| - </Button> |
62 |
| - {displayDialButton && ( |
63 |
| - <Button |
64 |
| - className="mx_RoomListSearch_button" |
65 |
| - kind="secondary" |
66 |
| - size="sm" |
67 |
| - Icon={DialPadIcon} |
68 |
| - iconOnly={true} |
69 |
| - aria-label={_t("left_panel|open_dial_pad")} |
70 |
| - onClick={(ev) => { |
71 |
| - defaultDispatcher.fire(Action.OpenDialPad); |
72 |
| - }} |
73 |
| - /> |
74 |
| - )} |
75 |
| - {displayExploreButton && ( |
76 |
| - <Button |
77 |
| - className="mx_RoomListSearch_button" |
78 |
| - kind="secondary" |
79 |
| - size="sm" |
80 |
| - Icon={ExploreIcon} |
81 |
| - iconOnly={true} |
82 |
| - aria-label={_t("action|explore_rooms")} |
83 |
| - onClick={(ev) => { |
84 |
| - defaultDispatcher.fire(Action.ViewRoomDirectory); |
85 |
| - PosthogTrackers.trackInteraction("WebLeftPanelExploreRoomsButton", ev); |
86 |
| - }} |
87 |
| - /> |
88 |
| - )} |
89 |
| - </Flex> |
90 |
| - ); |
| 17 | +export function RoomListSearch(): JSX.Element { |
| 18 | + const vm = useMemo(() => new RoomListSearchViewModel(), []); |
| 19 | + return <RoomListSearchView vm={vm} />; |
91 | 20 | }
|
0 commit comments