From be51dc5f12fdb4f08b55715888ce5fed6921230e Mon Sep 17 00:00:00 2001 From: Ginger Date: Sat, 13 Sep 2025 15:12:10 -0400 Subject: [PATCH] Revert "Add a page and config option for a room directory server" This reverts commit 401d8ed9304a948f5159338e7957479c7e8760cb. Revert "Minor styling changes" This reverts commit 3de1ce8f2f6f5e1e46d6496e65035820117a1661. Revert "Use consistent "bookmark" wording in code and UI" This reverts commit c45cb62e2d4772cdad6a75295bfac34ab57242c0. Revert "Move featured servers into the Featured section" This reverts commit 53612f46410b7bf920d928f327261c1e1e2477cd. --- .vscode/settings.json | 5 +- config.json | 12 +- src/app/components/info-card/styles.css.ts | 1 + src/app/components/room-card/RoomCard.tsx | 14 +- src/app/components/room-card/style.css.ts | 2 +- src/app/hooks/router/useExploreSelected.ts | 6 - src/app/hooks/useBookmarkedServers.ts | 43 ---- src/app/hooks/useClientConfig.ts | 1 - src/app/hooks/useExploreServers.ts | 43 ++++ src/app/pages/client/explore/Explore.tsx | 256 ++++++++++----------- src/app/pages/client/explore/Featured.tsx | 93 +------- src/app/pages/client/explore/Server.tsx | 178 +++++++------- src/types/matrix/accountData.ts | 2 +- 13 files changed, 279 insertions(+), 377 deletions(-) delete mode 100644 src/app/hooks/useBookmarkedServers.ts create mode 100644 src/app/hooks/useExploreServers.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index e1027687..8134a7fd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,8 +4,5 @@ "typescript.tsdk": "node_modules/typescript/lib", "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[typescriptreact]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" } -} \ No newline at end of file +} diff --git a/config.json b/config.json index e1f477d8..de6015a1 100644 --- a/config.json +++ b/config.json @@ -9,6 +9,7 @@ "xmr.se" ], "allowCustomHomeservers": true, + "featuredCommunities": { "openAsDefault": false, "spaces": [ @@ -27,16 +28,11 @@ "#PrivSec.dev:arcticfoxes.net", "#disroot:aria-net.org" ], - "servers": [ - "envs.net", - "matrix.org", - "monero.social", - "mozilla.org" - ], - "directoryServer": "matrixrooms.info" + "servers": ["envs.net", "matrix.org", "monero.social", "mozilla.org"] }, + "hashRouter": { "enabled": false, "basename": "/" } -} \ No newline at end of file +} diff --git a/src/app/components/info-card/styles.css.ts b/src/app/components/info-card/styles.css.ts index 68fe7f0a..c852fbcf 100644 --- a/src/app/components/info-card/styles.css.ts +++ b/src/app/components/info-card/styles.css.ts @@ -5,5 +5,6 @@ export const InfoCard = style([ { padding: config.space.S200, borderRadius: config.radii.R300, + borderWidth: config.borderWidth.B300, }, ]); diff --git a/src/app/components/room-card/RoomCard.tsx b/src/app/components/room-card/RoomCard.tsx index 3b40bafc..34a7e24b 100644 --- a/src/app/components/room-card/RoomCard.tsx +++ b/src/app/components/room-card/RoomCard.tsx @@ -45,7 +45,7 @@ const setGridColumnCount = (grid: HTMLElement, count: GridColumnCount): void => grid.style.setProperty('grid-template-columns', `repeat(${count}, 1fr)`); }; -export function CardGrid({ children }: { children: ReactNode }) { +export function RoomCardGrid({ children }: { children: ReactNode }) { const gridRef = useRef(null); useElementSizeObserver( @@ -60,17 +60,17 @@ export function CardGrid({ children }: { children: ReactNode }) { ); } -export const CardBase = as<'div'>(({ className, ...props }, ref) => ( +export const RoomCardBase = as<'div'>(({ className, ...props }, ref) => ( )); -export const CardName = as<'h6'>(({ ...props }, ref) => ( +export const RoomCardName = as<'h6'>(({ ...props }, ref) => ( )); @@ -208,7 +208,7 @@ export const RoomCard = as<'div', RoomCardProps>( const openTopic = () => setViewTopic(true); return ( - + ( )} - {roomName} + {roomName} {roomTopic} @@ -314,7 +314,7 @@ export const RoomCard = as<'div', RoomCardProps>( )} - + ); } ); diff --git a/src/app/components/room-card/style.css.ts b/src/app/components/room-card/style.css.ts index e8c640a8..b15acfe4 100644 --- a/src/app/components/room-card/style.css.ts +++ b/src/app/components/room-card/style.css.ts @@ -8,7 +8,7 @@ export const CardGrid = style({ gap: config.space.S400, }); -export const CardBase = style([ +export const RoomCardBase = style([ DefaultReset, ContainerColor({ variant: 'SurfaceVariant' }), { diff --git a/src/app/hooks/router/useExploreSelected.ts b/src/app/hooks/router/useExploreSelected.ts index 7ca00a13..be7615ca 100644 --- a/src/app/hooks/router/useExploreSelected.ts +++ b/src/app/hooks/router/useExploreSelected.ts @@ -1,6 +1,5 @@ import { useMatch, useParams } from 'react-router-dom'; import { getExploreFeaturedPath, getExplorePath } from '../../pages/pathUtils'; -import { useClientConfig } from '../useClientConfig'; export const useExploreSelected = (): boolean => { const match = useMatch({ @@ -27,8 +26,3 @@ export const useExploreServer = (): string | undefined => { return server; }; - -export const useDirectoryServer = (): string | undefined => { - const { featuredCommunities } = useClientConfig(); - return featuredCommunities?.directoryServer; -}; diff --git a/src/app/hooks/useBookmarkedServers.ts b/src/app/hooks/useBookmarkedServers.ts deleted file mode 100644 index fe49f974..00000000 --- a/src/app/hooks/useBookmarkedServers.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { useCallback, useMemo } from 'react'; -import { AccountDataEvent } from '../../types/matrix/accountData'; -import { useAccountData } from './useAccountData'; -import { useMatrixClient } from './useMatrixClient'; - -export type InCinnyBookmarkedServersContent = { - servers?: string[]; -}; - -export const useBookmarkedServers = (): [ - string[], - (server: string) => Promise, - (server: string) => Promise -] => { - const mx = useMatrixClient(); - const accountData = useAccountData(AccountDataEvent.CinnyBookmarkedServers); - const bookmarkedServers = useMemo( - () => accountData?.getContent()?.servers ?? [], - [accountData] - ); - - const addServerBookmark = useCallback( - async (server: string) => { - if (bookmarkedServers.indexOf(server) === -1) { - await mx.setAccountData(AccountDataEvent.CinnyBookmarkedServers, { - servers: [...bookmarkedServers, server], - }); - } - }, - [mx, bookmarkedServers] - ); - - const removeServerBookmark = useCallback( - async (server: string) => { - await mx.setAccountData(AccountDataEvent.CinnyBookmarkedServers, { - servers: bookmarkedServers.filter((addedServer) => server !== addedServer), - }); - }, - [mx, bookmarkedServers] - ); - - return [bookmarkedServers, addServerBookmark, removeServerBookmark]; -}; diff --git a/src/app/hooks/useClientConfig.ts b/src/app/hooks/useClientConfig.ts index 98d7eb92..e5fc6cc6 100644 --- a/src/app/hooks/useClientConfig.ts +++ b/src/app/hooks/useClientConfig.ts @@ -15,7 +15,6 @@ export type ClientConfig = { spaces?: string[]; rooms?: string[]; servers?: string[]; - directoryServer?: string; }; hashRouter?: HashRouterConfig; diff --git a/src/app/hooks/useExploreServers.ts b/src/app/hooks/useExploreServers.ts new file mode 100644 index 00000000..cc27baec --- /dev/null +++ b/src/app/hooks/useExploreServers.ts @@ -0,0 +1,43 @@ +import { useCallback, useMemo } from 'react'; +import { AccountDataEvent } from '../../types/matrix/accountData'; +import { useAccountData } from './useAccountData'; +import { useMatrixClient } from './useMatrixClient'; + +export type InCinnyExploreServersContent = { + servers?: string[]; +}; + +export const useExploreServers = (): [ + string[], + (server: string) => Promise, + (server: string) => Promise +] => { + const mx = useMatrixClient(); + const accountData = useAccountData(AccountDataEvent.CinnyExplore); + const userAddedServers = useMemo( + () => accountData?.getContent()?.servers ?? [], + [accountData] + ); + + const addServer = useCallback( + async (server: string) => { + if (userAddedServers.indexOf(server) === -1) { + await mx.setAccountData(AccountDataEvent.CinnyExplore, { + servers: [...userAddedServers, server], + }); + } + }, + [mx, userAddedServers] + ); + + const removeServer = useCallback( + async (server: string) => { + await mx.setAccountData(AccountDataEvent.CinnyExplore, { + servers: userAddedServers.filter((addedServer) => server !== addedServer), + }); + }, + [mx, userAddedServers] + ); + + return [userAddedServers, addServer, removeServer]; +}; diff --git a/src/app/pages/client/explore/Explore.tsx b/src/app/pages/client/explore/Explore.tsx index 4e06830e..e3a99c68 100644 --- a/src/app/pages/client/explore/Explore.tsx +++ b/src/app/pages/client/explore/Explore.tsx @@ -31,8 +31,8 @@ import { NavLink, } from '../../../components/nav'; import { getExploreFeaturedPath, getExploreServerPath } from '../../pathUtils'; +import { useClientConfig } from '../../../hooks/useClientConfig'; import { - useDirectoryServer, useExploreFeaturedRooms, useExploreServer, } from '../../../hooks/router/useExploreSelected'; @@ -42,21 +42,21 @@ import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback'; import { useNavToActivePathMapper } from '../../../hooks/useNavToActivePathMapper'; import { PageNav, PageNavContent, PageNavHeader } from '../../../components/page'; import { stopPropagation } from '../../../utils/keyboard'; -import { useBookmarkedServers } from '../../../hooks/useBookmarkedServers'; +import { useExploreServers } from '../../../hooks/useExploreServers'; import { useAlive } from '../../../hooks/useAlive'; -type ExploreServerPromptProps = { - onSubmit: (server: string, save: boolean) => Promise; +type AddExploreServerPromptProps = { + onSubmit: (server: string) => Promise; header: ReactNode; children: ReactNode; selected?: boolean; }; -export function ExploreServerPrompt({ +export function AddExploreServerPrompt({ onSubmit, header, children, selected = false, -}: ExploreServerPromptProps) { +}: AddExploreServerPromptProps) { const mx = useMatrixClient(); const [dialog, setDialog] = useState(false); const alive = useAlive(); @@ -69,27 +69,19 @@ export function ExploreServerPrompt({ return server || undefined; }; - const handleSubmit = useCallback( - async (saveBookmark: boolean) => { + const [submitState, handleSubmit] = useAsyncCallback( + useCallback(async () => { const server = getInputServer(); if (!server) return; await mx.publicRooms({ server, limit: 1 }); - await onSubmit(server, saveBookmark); + await onSubmit(server); if (alive()) { setDialog(false); } - }, - [alive, onSubmit, mx] + }, [alive, onSubmit, mx]) ); - const [viewState, handleView] = useAsyncCallback(() => handleSubmit(false)); - const [saveViewState, handleSaveView] = useAsyncCallback(() => handleSubmit(true)); - const busy = - viewState.status === AsyncStatus.Loading || saveViewState.status === AsyncStatus.Loading; - const failed = - viewState.status === AsyncStatus.Error || saveViewState.status === AsyncStatus.Error; - return ( <> }> @@ -116,46 +108,41 @@ export function ExploreServerPrompt({ - + { + evt.preventDefault(); + handleSubmit(); + }} + style={{ padding: config.space.S400 }} + direction="Column" + gap="400" + > Add server name to explore public communities. Server Name - {failed && ( + {submitState.status === AsyncStatus.Error && ( Failed to load public rooms. Please try again. )} - - - - + + + @@ -171,34 +158,30 @@ export function ExploreServerPrompt({ ); } -type ExploreServerNavItemAction = { - onClick: () => Promise; - icon: IconSrc; - filled?: boolean; - alwaysVisible: boolean; -}; type ExploreServerNavItemProps = { server: string; selected: boolean; icon: IconSrc; - action?: ExploreServerNavItemAction; + onRemove?: (() => Promise) | null; }; export function ExploreServerNavItem({ server, selected, icon, - action, + onRemove = null, }: ExploreServerNavItemProps) { const [hover, setHover] = useState(false); const { hoverProps } = useHover({ onHoverChange: setHover }); const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: setHover }); - const [actionState, actionCallback] = useAsyncCallback( + const [removeState, removeCallback] = useAsyncCallback( useCallback(async () => { - await action?.onClick(); - }, [action]) + if (onRemove !== null) { + await onRemove(); + } + }, [onRemove]) ); - const actionInProgress = - actionState.status === AsyncStatus.Loading || actionState.status === AsyncStatus.Success; + const removeInProgress = + removeState.status === AsyncStatus.Loading || removeState.status === AsyncStatus.Success; return ( - {action !== undefined && (hover || actionInProgress || action.alwaysVisible) && ( + {onRemove !== null && (hover || removeInProgress) && ( - {actionInProgress ? ( - + {removeInProgress ? ( + ) : ( - + )} @@ -250,39 +232,50 @@ export function Explore() { const navigate = useNavigate(); useNavToActivePathMapper('explore'); const userId = mx.getUserId(); + const clientConfig = useClientConfig(); const userServer = userId ? getMxIdServer(userId) : undefined; - const directoryServer = useDirectoryServer(); - const [bookmarkedServers, addServerBookmark, removeServerBookmark] = useBookmarkedServers(); - const selectedServer = useExploreServer(); + const featuredServers = useMemo( + () => + clientConfig.featuredCommunities?.servers?.filter((server) => server !== userServer) ?? [], + [clientConfig, userServer] + ); + const [exploreServers, addServer, removeServer] = useExploreServers(); + const selectedServer = useExploreServer(); const exploringFeaturedRooms = useExploreFeaturedRooms(); - const exploringDirectory = directoryServer !== undefined && selectedServer === directoryServer; const exploringUnlistedServer = useMemo( () => !( selectedServer === undefined || selectedServer === userServer || - exploringDirectory || - bookmarkedServers.includes(selectedServer) + featuredServers.includes(selectedServer) || + exploreServers.includes(selectedServer) ), - [bookmarkedServers, selectedServer, userServer, exploringDirectory] + [exploreServers, featuredServers, selectedServer, userServer] ); - const viewServerCallback = useCallback( - async (server: string, saveBookmark: boolean) => { - if (saveBookmark && server !== userServer && server !== directoryServer && selectedServer) { - await addServerBookmark(server); + const addServerCallback = useCallback( + async (server: string) => { + if (server !== userServer && selectedServer && !featuredServers.includes(selectedServer)) { + await addServer(server); } navigate(getExploreServerPath(server)); }, - [addServerBookmark, navigate, userServer, directoryServer, selectedServer] + [addServer, navigate, userServer, featuredServers, selectedServer] ); - const removeServerBookmarkCallback = useCallback( + const removeServerCallback = useCallback( async (server: string) => { - await removeServerBookmark(server); + await removeServer(server); }, - [removeServerBookmark] + [removeServer] + ); + + const exploreUnlistedServerCallback = useCallback( + async (server: string) => { + navigate(getExploreServerPath(server)); + }, + [navigate] ); return ( @@ -300,6 +293,29 @@ export function Explore() { + View Server} + selected={exploringUnlistedServer} + > + + + + + + + Explore with Address + + + + + + + + + Featured + + @@ -309,31 +325,13 @@ export function Explore() { - Featured + Featured Rooms - {directoryServer && ( - - - - - - - - - - Public Room Directory - - - - - - - )} {userServer && ( )} - {exploringUnlistedServer && selectedServer !== undefined && ( - viewServerCallback(selectedServer, true), - }} - /> - )} - - - - - Bookmarks - - - {bookmarkedServers.map((server) => ( + {featuredServers.map((server) => ( removeServerBookmarkCallback(server), - }} /> ))} - + + + + Servers + + + {exploreServers.map((server) => ( + removeServerCallback(server)} + icon={Icons.Server} + /> + ))} + Add Server} > @@ -387,7 +377,7 @@ export function Explore() { - + diff --git a/src/app/pages/client/explore/Featured.tsx b/src/app/pages/client/explore/Featured.tsx index c344657a..f056cbb5 100644 --- a/src/app/pages/client/explore/Featured.tsx +++ b/src/app/pages/client/explore/Featured.tsx @@ -1,10 +1,8 @@ -import React, { useCallback } from 'react'; -import { Box, Button, color, Icon, IconButton, Icons, Scroll, Spinner, Text } from 'folds'; +import React from 'react'; +import { Box, Icon, IconButton, Icons, Scroll, Text } from 'folds'; import { useAtomValue } from 'jotai'; -import { useQuery } from '@tanstack/react-query'; -import { useNavigate } from 'react-router-dom'; import { useClientConfig } from '../../../hooks/useClientConfig'; -import { RoomCard, CardGrid, CardName, CardBase } from '../../../components/room-card'; +import { RoomCard, RoomCardGrid } from '../../../components/room-card'; import { allRoomsAtom } from '../../../state/room-list/roomList'; import { RoomSummaryLoader } from '../../../components/RoomSummaryLoader'; import { @@ -20,69 +18,13 @@ import * as css from './style.css'; import { useRoomNavigate } from '../../../hooks/useRoomNavigate'; import { ScreenSize, useScreenSizeContext } from '../../../hooks/useScreenSize'; import { BackRouteHandler } from '../../../components/BackRouteHandler'; -import { useMatrixClient } from '../../../hooks/useMatrixClient'; -import { millify } from '../../../plugins/millify'; -import { getExploreServerPath } from '../../pathUtils'; - -type ServerCardProps = { - serverName: string; - onExplore: () => unknown; -}; - -function ServerCard({ serverName, onExplore }: ServerCardProps) { - const mx = useMatrixClient(); - - const fetchPublicRooms = useCallback( - () => mx.publicRooms({ server: serverName }), - [mx, serverName] - ); - - const { data, isLoading, isError } = useQuery({ - queryKey: [serverName, `publicRooms`], - queryFn: fetchPublicRooms, - }); - const publicRoomCount = data?.total_room_count_estimate; - - return ( - - {serverName} - - {isLoading ? ( - - ) : ( - <> - - - {publicRoomCount === undefined - ? 'Error loading rooms' - : `${millify(publicRoomCount)} Public Rooms`} - - - )} - - - - ); -} export function FeaturedRooms() { const { featuredCommunities } = useClientConfig(); - const { rooms, spaces, servers } = featuredCommunities ?? {}; + const { rooms, spaces } = featuredCommunities ?? {}; const allRooms = useAtomValue(allRoomsAtom); const screenSize = useScreenSizeContext(); const { navigateSpace, navigateRoom } = useRoomNavigate(); - const navigate = useNavigate(); - - const exploreServer = useCallback( - async (server: string) => { - navigate(getExploreServerPath(server)); - }, - [navigate] - ); return ( @@ -107,28 +49,15 @@ export function FeaturedRooms() { } - title="Featured" - subTitle="Find and explore public communities featured by your client provider." + title="Featured by Client" + subTitle="Find and explore public rooms and spaces featured by client provider." /> - {servers && servers.length > 0 && ( - - Featured Servers - - {servers.map((serverName) => ( - exploreServer(serverName)} - /> - ))} - - - )} {spaces && spaces.length > 0 && ( Featured Spaces - + {spaces.map((roomIdOrAlias) => ( {(roomSummary) => ( @@ -151,13 +80,13 @@ export function FeaturedRooms() { )} ))} - + )} {rooms && rooms.length > 0 && ( Featured Rooms - + {rooms.map((roomIdOrAlias) => ( {(roomSummary) => ( @@ -180,7 +109,7 @@ export function FeaturedRooms() { )} ))} - + )} {((spaces && spaces.length === 0 && rooms && rooms.length === 0) || @@ -194,7 +123,7 @@ export function FeaturedRooms() { > - No rooms or spaces are featured. + No rooms or spaces featured by client provider. )} diff --git a/src/app/pages/client/explore/Server.tsx b/src/app/pages/client/explore/Server.tsx index 0c47e5a4..9a0618a1 100644 --- a/src/app/pages/client/explore/Server.tsx +++ b/src/app/pages/client/explore/Server.tsx @@ -9,13 +9,11 @@ import React, { useState, } from 'react'; import { - Badge, Box, Button, Chip, Icon, IconButton, - IconSrc, Icons, Input, Line, @@ -39,7 +37,7 @@ import { MatrixClient, Method, RoomType } from 'matrix-js-sdk'; import { Page, PageContent, PageContentCenter, PageHeader } from '../../../components/page'; import { useMatrixClient } from '../../../hooks/useMatrixClient'; import { RoomTopicViewer } from '../../../components/room-topic-viewer'; -import { RoomCard, CardBase, CardGrid } from '../../../components/room-card'; +import { RoomCard, RoomCardBase, RoomCardGrid } from '../../../components/room-card'; import { ExploreServerPathSearchParams } from '../../paths'; import { getExploreServerPath, withSearchParam } from '../../pathUtils'; import * as css from './style.css'; @@ -50,8 +48,7 @@ import { stopPropagation } from '../../../utils/keyboard'; import { ScreenSize, useScreenSizeContext } from '../../../hooks/useScreenSize'; import { BackRouteHandler } from '../../../components/BackRouteHandler'; import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback'; -import { useBookmarkedServers } from '../../../hooks/useBookmarkedServers'; -import { useDirectoryServer } from '../../../hooks/router/useExploreSelected'; +import { useExploreServers } from '../../../hooks/useExploreServers'; const useServerSearchParams = (searchParams: URLSearchParams): ExploreServerPathSearchParams => useMemo( @@ -352,10 +349,10 @@ export function PublicRooms() { const mx = useMatrixClient(); const userId = mx.getUserId(); const userServer = userId && getMxIdServer(userId); - const directoryServer = useDirectoryServer(); const allRooms = useAtomValue(allRoomsAtom); const { navigateSpace, navigateRoom } = useRoomNavigate(); const screenSize = useScreenSizeContext(); + const [menuAnchor, setMenuAnchor] = useState(); const [searchParams] = useSearchParams(); const serverSearchParams = useServerSearchParams(searchParams); @@ -364,18 +361,9 @@ export function PublicRooms() { const searchInputRef = useRef(null); const navigate = useNavigate(); const roomTypeFilters = useRoomTypeFilters(); - const [bookmarkedServers, addServerBookmark, removeServerBookmark] = useBookmarkedServers(); - const isUserHomeserver = server !== undefined && server === userServer; - const isBookmarkedServer = server !== undefined && bookmarkedServers.includes(server); - const isDirectoryServer = server !== undefined && server === directoryServer; - let headerIcon: IconSrc; - if (isUserHomeserver) { - headerIcon = Icons.Home; - } else if (isDirectoryServer) { - headerIcon = Icons.Search; - } else { - headerIcon = Icons.Server; - } + const [exploreServers, , removeServer] = useExploreServers(); + const isUserAddedServer = server && exploreServers.includes(server); + const isUserHomeServer = server && server === userServer; const currentLimit: number = useMemo(() => { const limitParam = serverSearchParams.limit; @@ -488,17 +476,19 @@ export function PublicRooms() { explore({ instance: instanceId, since: undefined }); }; - const [bookmarkActionState, handleBookmarkAction] = useAsyncCallback( - useCallback( - async (action: (server: string) => Promise) => { - if (!server) return; + const handleOpenMenu: MouseEventHandler = (evt) => { + setMenuAnchor(evt.currentTarget.getBoundingClientRect()); + }; - await action(server); - }, - [server] - ) + const [removeServerState, handleRemoveServer] = useAsyncCallback( + useCallback(async () => { + if (!server) return; + + setMenuAnchor(undefined); + await removeServer(server); + }, [server, removeServer]) ); - const bookmarkActionLoading = bookmarkActionState.status === AsyncStatus.Loading; + const isRemoving = removeServerState.status === AsyncStatus.Loading; return ( @@ -539,70 +529,76 @@ export function PublicRooms() { )} - {screenSize !== ScreenSize.Mobile && } + {screenSize !== ScreenSize.Mobile && } - {isDirectoryServer ? 'Public Room Directory' : server} + {server} - {isDirectoryServer ? ( - - provided by {directoryServer} - - } - > - {(triggerRef) => ( - } + + More Options + + } + > + {(triggerRef) => + isUserAddedServer && ( + - - provided by {directoryServer} - - - )} - - ) : ( - - {isBookmarkedServer ? 'Remove Bookmark' : 'Add Bookmark'} - - } - > - {(triggerRef) => - !isUserHomeserver && ( - - handleBookmarkAction( - isBookmarkedServer ? removeServerBookmark : addServerBookmark - ) - } - ref={triggerRef} - disabled={bookmarkActionLoading} - > - - - ) - } - - )} + + + ) + } + + setMenuAnchor(undefined), + clickOutsideDeactivates: true, + isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown', + isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp', + escapeDeactivates: stopPropagation, + }} + > + + + + ) : ( + + ) + } + radii="300" + disabled={isRemoving} + > + + Remove Server + + + + + + } + /> )} @@ -664,11 +660,11 @@ export function PublicRooms() { {isLoading && ( - + {[...Array(currentLimit).keys()].map((item) => ( - + ))} - + )} {error && ( @@ -679,7 +675,7 @@ export function PublicRooms() { {data && (data.chunk.length > 0 ? ( <> - + {data?.chunk.map((chunkRoom) => ( ))} - + {(data.prev_batch || data.next_batch) && ( diff --git a/src/types/matrix/accountData.ts b/src/types/matrix/accountData.ts index 4bb6f5c2..b9d81492 100644 --- a/src/types/matrix/accountData.ts +++ b/src/types/matrix/accountData.ts @@ -4,7 +4,7 @@ export enum AccountDataEvent { IgnoredUserList = 'm.ignored_user_list', CinnySpaces = 'in.cinny.spaces', - CinnyBookmarkedServers = 'in.cinny.bookmarked_servers', + CinnyExplore = 'in.cinny.explore', ElementRecentEmoji = 'io.element.recent_emoji',