From bd53aaa96a6b7285033c2d313d4ca87d7c696327 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Fri, 28 Aug 2026 17:20:22 +0530 Subject: [PATCH] show room access indicator on room header --- src/app/components/RoomAccessIndicator.tsx | 41 ++++++++++++++++++++++ src/app/features/room/RoomViewHeader.tsx | 10 ++++-- src/app/pages/client/space/Space.tsx | 8 ++--- 3 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 src/app/components/RoomAccessIndicator.tsx diff --git a/src/app/components/RoomAccessIndicator.tsx b/src/app/components/RoomAccessIndicator.tsx new file mode 100644 index 00000000..08716ddd --- /dev/null +++ b/src/app/components/RoomAccessIndicator.tsx @@ -0,0 +1,41 @@ +import { Icon, Icons, IconSrc, Text, Tooltip, TooltipProvider } from 'folds'; +import React from 'react'; +import { JoinRule } from '../../types/matrix/room'; +import { useClient } from '../hooks/useClient'; +import { useObservableValue } from '../hooks/useObservableValue'; +import { useRoomJoinRuleLabel } from './JoinRulesSwitcher'; + +export const getRoomAccessIconSrc = (joinRule?: JoinRule): IconSrc | undefined => { + if (!joinRule) return Icons.Lock; + + if (joinRule === 'public') return Icons.Globe; + if (joinRule === 'invite' || joinRule === 'knock' || joinRule === 'private') { + return Icons.Lock; + } + + return undefined; +}; + +export function RoomAccessIndicator({ roomId }: { roomId: string }) { + const ct = useClient(); + const roomToJoinRule = useObservableValue(ct.roomToJoinRule); + + const ruleToLabels = useRoomJoinRuleLabel(); + + const iconSrc = getRoomAccessIconSrc(roomToJoinRule.get(roomId)); + if (!iconSrc) return null; + + return ( + + {ruleToLabels[roomToJoinRule.get(roomId) ?? 'private']} + + } + > + {(triggerRef) => } + + ); +} diff --git a/src/app/features/room/RoomViewHeader.tsx b/src/app/features/room/RoomViewHeader.tsx index 26dacb10..20c2dadb 100644 --- a/src/app/features/room/RoomViewHeader.tsx +++ b/src/app/features/room/RoomViewHeader.tsx @@ -70,6 +70,7 @@ import { import { roomToNotificationsAtom } from '../../state/room/roomToNotifications'; import { ContainerColor } from '../../styles/ContainerColor.css'; import { RoomSettingsPage } from '../../state/roomSettings'; +import { RoomAccessIndicator } from '../../components/RoomAccessIndicator'; type RoomMenuProps = { requestClose: () => void; @@ -352,9 +353,12 @@ export function RoomViewHeader({ callView }: { callView?: boolean }) { )} - - {name} - + + + {name} + + + {topic && ( {(viewTopic, setViewTopic) => ( diff --git a/src/app/pages/client/space/Space.tsx b/src/app/pages/client/space/Space.tsx index 768fba50..dd023017 100644 --- a/src/app/pages/client/space/Space.tsx +++ b/src/app/pages/client/space/Space.tsx @@ -92,6 +92,7 @@ import { getJoinRoomStateId } from '../../../../client/storage/collections'; import { useAllJoinedRoomsSet } from '../../../hooks/useGetRoom'; import { unreadRoomsAtom } from '../../../state/room/roomToUnread'; import { useRoomsUnread } from '../../../state/hooks/unread'; +import { RoomAccessIndicator } from '../../../components/RoomAccessIndicator'; type SpaceMenuProps = { requestClose: () => void; @@ -239,11 +240,8 @@ type SpaceHeaderProps = { spaceName: string; }; function SpaceHeader({ spaceName }: SpaceHeaderProps) { - const ct = useClient(); const spaceId = useSpace(); const [menuAnchor, setMenuAnchor] = useState(); - const roomToJoinRule = useObservableValue(ct.roomToJoinRule); - const joinRule = roomToJoinRule.get(spaceId); const handleOpenMenu: MouseEventHandler = (evt) => { const cords = evt.currentTarget.getBoundingClientRect(); @@ -257,11 +255,11 @@ function SpaceHeader({ spaceName }: SpaceHeaderProps) { <> - + {spaceName} - {joinRule !== 'public' && } +