8ebb1a8d8c
Key v4.12.1 changes merged: - Security: sanitize-html updated to v2.17.4 - Calling: video calls in DMs/rooms, user avatars during calls, right-click to start - Calling: IncomingCallListener with ring sound and answer/reject UI - Editor: list crash fixes (Firefox + empty headings), codeblock filename support - Media: URL preview hover state, keyboard nav, click-to-open, OGG audio support - Date: ISO 8601 (YYYY-MM-DD) date format option - Misc: stable mutual rooms endpoint, Android notification crash fix Lotus customisations preserved: - PiP drag/resize, DM call ring notification, PTT, GIF picker, noise suppression - Poll voting, message forwarding, image captions, location sharing - Lotus Terminal design theme
93 lines
3.2 KiB
TypeScript
93 lines
3.2 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 } from 'jotai';
|
|
import { RoomView } from './RoomView';
|
|
import { MembersDrawer } from './MembersDrawer';
|
|
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, useIsDirectRoom } 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(room, callSession);
|
|
const callEmbed = useCallEmbed();
|
|
|
|
const [isDrawer] = useSetting(settingsAtom, 'isPeopleDrawer');
|
|
const [hideActivity] = useSetting(settingsAtom, 'hideActivity');
|
|
const screenSize = useScreenSizeContext();
|
|
const powerLevels = usePowerLevels(room);
|
|
const members = useRoomMembers(mx, room.roomId);
|
|
const chat = useAtomValue(callChatAtom);
|
|
const isDirect = useIsDirectRoom();
|
|
|
|
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 && screenSize === ScreenSize.Desktop && isDrawer && (
|
|
<>
|
|
<Line variant="Background" direction="Vertical" size="300" />
|
|
<MembersDrawer key={room.roomId} room={room} members={members} />
|
|
</>
|
|
)}
|
|
</Box>
|
|
</PowerLevelsContextProvider>
|
|
);
|
|
}
|