2024-07-18 18:50:20 +05:30
|
|
|
import React, { useCallback } from 'react';
|
2024-05-31 19:49:46 +05:30
|
|
|
import { Box, Line } from 'folds';
|
|
|
|
|
import { useParams } from 'react-router-dom';
|
2024-07-18 18:50:20 +05:30
|
|
|
import { isKeyHotkey } from 'is-hotkey';
|
2026-03-07 18:03:32 +11:00
|
|
|
import { useAtomValue } from 'jotai';
|
2024-05-31 19:49:46 +05:30
|
|
|
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 } from '../../hooks/useRoom';
|
2024-07-18 18:50:20 +05:30
|
|
|
import { useKeyDown } from '../../hooks/useKeyDown';
|
2025-08-29 15:04:52 +05:30
|
|
|
import { markAsRead } from '../../utils/notifications';
|
2024-07-22 16:17:19 +05:30
|
|
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
2024-07-23 10:45:17 +05:30
|
|
|
import { useRoomMembers } from '../../hooks/useRoomMembers';
|
2026-03-07 18:03:32 +11:00
|
|
|
import { CallView } from '../call/CallView';
|
|
|
|
|
import { RoomViewHeader } from './RoomViewHeader';
|
|
|
|
|
import { callChatAtom } from '../../state/callEmbed';
|
|
|
|
|
import { CallChatView } from './CallChatView';
|
2024-05-31 19:49:46 +05:30
|
|
|
|
|
|
|
|
export function Room() {
|
|
|
|
|
const { eventId } = useParams();
|
|
|
|
|
const room = useRoom();
|
2024-07-22 16:17:19 +05:30
|
|
|
const mx = useMatrixClient();
|
2024-05-31 19:49:46 +05:30
|
|
|
|
|
|
|
|
const [isDrawer] = useSetting(settingsAtom, 'isPeopleDrawer');
|
2025-02-26 21:44:53 +11:00
|
|
|
const [hideActivity] = useSetting(settingsAtom, 'hideActivity');
|
2024-05-31 19:49:46 +05:30
|
|
|
const screenSize = useScreenSizeContext();
|
|
|
|
|
const powerLevels = usePowerLevels(room);
|
2024-07-23 10:45:17 +05:30
|
|
|
const members = useRoomMembers(mx, room.roomId);
|
2026-03-07 18:03:32 +11:00
|
|
|
const chat = useAtomValue(callChatAtom);
|
2024-05-31 19:49:46 +05:30
|
|
|
|
2024-07-18 18:50:20 +05:30
|
|
|
useKeyDown(
|
|
|
|
|
window,
|
|
|
|
|
useCallback(
|
|
|
|
|
(evt) => {
|
2024-09-08 22:53:17 +10:00
|
|
|
if (isKeyHotkey('escape', evt)) {
|
2025-02-26 21:44:53 +11:00
|
|
|
markAsRead(mx, room.roomId, hideActivity);
|
2024-07-18 18:50:20 +05:30
|
|
|
}
|
|
|
|
|
},
|
2025-02-26 21:44:53 +11:00
|
|
|
[mx, room.roomId, hideActivity]
|
2024-07-18 18:50:20 +05:30
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2026-03-07 18:03:32 +11:00
|
|
|
const callView = room.isCallRoom();
|
|
|
|
|
|
2024-05-31 19:49:46 +05:30
|
|
|
return (
|
|
|
|
|
<PowerLevelsContextProvider value={powerLevels}>
|
|
|
|
|
<Box grow="Yes">
|
2026-03-07 18:03:32 +11:00
|
|
|
{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 && (
|
2024-05-31 19:49:46 +05:30
|
|
|
<>
|
|
|
|
|
<Line variant="Background" direction="Vertical" size="300" />
|
2024-07-23 10:45:17 +05:30
|
|
|
<MembersDrawer key={room.roomId} room={room} members={members} />
|
2024-05-31 19:49:46 +05:30
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
</PowerLevelsContextProvider>
|
|
|
|
|
);
|
|
|
|
|
}
|