4a4dede105
The real reason the gallery didn't look or function like the Members drawer
or Saved Messages: it was a position:fixed overlay floating over the timeline,
mounted from RoomViewHeader. Now it docks into the room layout row exactly like
MembersDrawer.
- new mediaGalleryAtom (mirrors bookmarksPanelAtom) holds the open state
- RoomViewHeader toggles the atom instead of local useState and no longer
renders the panel
- Room.tsx renders <MediaGallery> as a flex sibling of the timeline with a
vertical Line separator on desktop and key={room.roomId} to reset per room
- MediaGallery.css: static width on desktop, position:fixed inset:0 full-screen
only on mobile (identical strategy to MembersDrawer.css); root Box shrink="No"
The panel now shares the row with the timeline instead of overlapping it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
105 lines
3.7 KiB
TypeScript
105 lines
3.7 KiB
TypeScript
import React, { useCallback } from 'react';
|
|
import { Box, Line } from 'folds';
|
|
import { useParams } from 'react-router-dom';
|
|
import { isKeyHotkey } from 'is-hotkey';
|
|
import { useAtomValue, useSetAtom } from 'jotai';
|
|
import { RoomView } from './RoomView';
|
|
import { MembersDrawer } from './MembersDrawer';
|
|
import { MediaGallery } from './MediaGallery';
|
|
import { mediaGalleryAtom } from '../../state/mediaGallery';
|
|
import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize';
|
|
import { useSetting } from '../../state/hooks/settings';
|
|
import { settingsAtom } from '../../state/settings';
|
|
import { PowerLevelsContextProvider, usePowerLevels } from '../../hooks/usePowerLevels';
|
|
import { useRoom } from '../../hooks/useRoom';
|
|
import { useKeyDown } from '../../hooks/useKeyDown';
|
|
import { markAsRead } from '../../utils/notifications';
|
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
|
import { useRoomMembers } from '../../hooks/useRoomMembers';
|
|
import { CallView } from '../call/CallView';
|
|
import { RoomViewHeader } from './RoomViewHeader';
|
|
import { callChatAtom } from '../../state/callEmbed';
|
|
import { CallChatView } from './CallChatView';
|
|
import { useCallEmbed } from '../../hooks/useCallEmbed';
|
|
import { useCallMembers, useCallSession } from '../../hooks/useCall';
|
|
|
|
export function Room() {
|
|
const { eventId } = useParams();
|
|
const room = useRoom();
|
|
const mx = useMatrixClient();
|
|
|
|
const callSession = useCallSession(room);
|
|
const callMembers = useCallMembers(callSession);
|
|
const callEmbed = useCallEmbed();
|
|
|
|
const [isDrawer] = useSetting(settingsAtom, 'isPeopleDrawer');
|
|
const galleryOpen = useAtomValue(mediaGalleryAtom);
|
|
const setGalleryOpen = useSetAtom(mediaGalleryAtom);
|
|
const [hideActivity] = useSetting(settingsAtom, 'hideActivity');
|
|
const screenSize = useScreenSizeContext();
|
|
const powerLevels = usePowerLevels(room);
|
|
const members = useRoomMembers(mx, room.roomId);
|
|
const chat = useAtomValue(callChatAtom);
|
|
useKeyDown(
|
|
window,
|
|
useCallback(
|
|
(evt) => {
|
|
if (isKeyHotkey('escape', evt)) {
|
|
markAsRead(mx, room.roomId, hideActivity);
|
|
}
|
|
},
|
|
[mx, room.roomId, hideActivity],
|
|
),
|
|
);
|
|
|
|
const callView = callEmbed?.roomId === room.roomId || room.isCallRoom() || callMembers.length > 0;
|
|
|
|
return (
|
|
<PowerLevelsContextProvider value={powerLevels}>
|
|
<Box grow="Yes">
|
|
{callView && (screenSize === ScreenSize.Desktop || !chat) && (
|
|
<Box grow="Yes" direction="Column">
|
|
<RoomViewHeader callView />
|
|
<Box grow="Yes">
|
|
<CallView />
|
|
</Box>
|
|
</Box>
|
|
)}
|
|
{!callView && (
|
|
<Box grow="Yes" direction="Column">
|
|
<RoomViewHeader />
|
|
<Box grow="Yes">
|
|
<RoomView eventId={eventId} />
|
|
</Box>
|
|
</Box>
|
|
)}
|
|
|
|
{callView && chat && (
|
|
<>
|
|
{screenSize === ScreenSize.Desktop && (
|
|
<Line variant="Background" direction="Vertical" size="300" />
|
|
)}
|
|
<CallChatView />
|
|
</>
|
|
)}
|
|
{!callView && galleryOpen && (
|
|
<>
|
|
{screenSize === ScreenSize.Desktop && (
|
|
<Line variant="Background" direction="Vertical" size="300" />
|
|
)}
|
|
<MediaGallery key={room.roomId} room={room} onClose={() => setGalleryOpen(false)} />
|
|
</>
|
|
)}
|
|
{!callView && isDrawer && (
|
|
<>
|
|
{screenSize === ScreenSize.Desktop && (
|
|
<Line variant="Background" direction="Vertical" size="300" />
|
|
)}
|
|
<MembersDrawer key={room.roomId} room={room} members={members} />
|
|
</>
|
|
)}
|
|
</Box>
|
|
</PowerLevelsContextProvider>
|
|
);
|
|
}
|