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';
|
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';
|
|
|
|
|
import { markAsRead } from '../../../client/action/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';
|
2025-05-23 01:24:32 -05:00
|
|
|
import { CallView } from '../call/CallView';
|
2025-05-22 20:02:35 -05:00
|
|
|
import { useCallState } from '../../pages/client/call/CallProvider';
|
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');
|
2025-05-10 08:58:32 -05:00
|
|
|
const { isChatOpen } = useCallState();
|
2024-05-31 19:49:46 +05:30
|
|
|
const screenSize = useScreenSizeContext();
|
|
|
|
|
const powerLevels = usePowerLevels(room);
|
2025-05-08 18:01:27 -05:00
|
|
|
const members = useRoomMembers(mx, room?.roomId);
|
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
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2024-05-31 19:49:46 +05:30
|
|
|
return (
|
|
|
|
|
<PowerLevelsContextProvider value={powerLevels}>
|
2025-05-08 18:01:27 -05:00
|
|
|
<Box
|
|
|
|
|
grow="Yes"
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
display: 'flex',
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<CallView room={room} eventId={eventId} />
|
2025-05-10 08:58:32 -05:00
|
|
|
{(!room.isCallRoom() || isChatOpen) && (
|
|
|
|
|
<Box
|
|
|
|
|
grow="Yes"
|
|
|
|
|
style={{
|
|
|
|
|
width: room.isCallRoom() ? (isChatOpen ? '40%' : '0%') : '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
display: 'flex',
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box style={{ flex: 1, minHeight: 0, overflowY: 'auto', background: '#fff' }}>
|
|
|
|
|
<RoomView room={room} eventId={eventId} />
|
|
|
|
|
</Box>
|
2025-05-08 18:01:27 -05:00
|
|
|
</Box>
|
2025-05-10 08:58:32 -05:00
|
|
|
)}
|
2025-05-11 19:11:21 -05:00
|
|
|
{screenSize === ScreenSize.Desktop && !room.isCallRoom() && isDrawer && (
|
2025-05-11 19:09:39 -05:00
|
|
|
<>
|
|
|
|
|
<Line variant="Background" direction="Vertical" size="300" />
|
|
|
|
|
<MembersDrawer key={room.roomId} room={room} members={members} />
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2024-05-31 19:49:46 +05:30
|
|
|
</Box>
|
|
|
|
|
</PowerLevelsContextProvider>
|
|
|
|
|
);
|
|
|
|
|
}
|