2025-05-08 17:59:51 -05:00
|
|
|
import React, { ReactNode, useMemo, useRef } from 'react';
|
2024-05-31 19:49:46 +05:30
|
|
|
import { Box } from 'folds';
|
2025-05-08 17:59:51 -05:00
|
|
|
import { Outlet, useParams } from 'react-router-dom';
|
2025-04-16 20:45:33 -05:00
|
|
|
import { useCallState } from './CallProvider';
|
2025-04-15 22:16:35 -05:00
|
|
|
import { PersistentCallContainer } from '../call/PersistentCallContainer';
|
2025-05-02 17:04:11 -05:00
|
|
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
2025-05-08 17:59:51 -05:00
|
|
|
import { ClientWidgetApi } from 'matrix-widget-api';
|
|
|
|
|
import { SmallWidget } from '../../features/room/SmallWidget';
|
2024-05-31 19:49:46 +05:30
|
|
|
|
|
|
|
|
type ClientLayoutProps = {
|
|
|
|
|
nav: ReactNode;
|
|
|
|
|
};
|
2025-05-09 09:35:13 -05:00
|
|
|
export function ClientLayout({ nav }: ClientLayoutProps) {
|
2025-04-15 22:16:35 -05:00
|
|
|
const { activeCallRoomId } = useCallState();
|
2025-05-08 17:59:51 -05:00
|
|
|
const iframeRef = useRef<HTMLIFrameElement | null>(null);
|
|
|
|
|
const widgetApiRef = useRef<ClientWidgetApi | null>(null);
|
|
|
|
|
const smallWidgetRef = useRef<SmallWidget | null>(null);
|
|
|
|
|
|
|
|
|
|
const backupIframeRef = useRef<HTMLIFrameElement | null>(null);
|
|
|
|
|
const backupWidgetApiRef = useRef<ClientWidgetApi | null>(null);
|
|
|
|
|
const backupSmallWidgetRef = useRef<SmallWidget | null>(null);
|
2025-04-15 22:16:35 -05:00
|
|
|
const { roomIdOrAlias: viewedRoomId } = useParams();
|
2025-05-02 17:04:11 -05:00
|
|
|
const mx = useMatrixClient();
|
|
|
|
|
const isCall = mx.getRoom(viewedRoomId)?.isCallRoom();
|
|
|
|
|
|
2024-05-31 19:49:46 +05:30
|
|
|
return (
|
2025-04-15 22:16:35 -05:00
|
|
|
<Box grow="Yes" direction="Row" style={{ height: '100vh', width: '100vw', overflow: 'hidden' }}>
|
|
|
|
|
<Box shrink="No" className="nav-container-styles">
|
|
|
|
|
{nav}
|
|
|
|
|
</Box>
|
|
|
|
|
<Box grow="Yes" direction="Column" style={{ position: 'relative', overflowY: 'auto' }}>
|
|
|
|
|
<Box grow="Yes" style={{ position: 'relative' }}>
|
2025-05-08 17:59:51 -05:00
|
|
|
<PersistentCallContainer
|
|
|
|
|
isVisible={false}
|
|
|
|
|
viewedRoomId={viewedRoomId}
|
|
|
|
|
iframeRef={iframeRef}
|
|
|
|
|
widgetApiRef={widgetApiRef}
|
|
|
|
|
smallWidgetRef={smallWidgetRef}
|
|
|
|
|
backupIframeRef={backupIframeRef}
|
|
|
|
|
backupWidgetApiRef={backupWidgetApiRef}
|
|
|
|
|
backupSmallWidgetRef={backupSmallWidgetRef}
|
|
|
|
|
/>
|
2025-04-15 22:16:35 -05:00
|
|
|
<Box
|
|
|
|
|
grow="Yes"
|
|
|
|
|
style={{
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
}}
|
|
|
|
|
className="outlet-wrapper"
|
|
|
|
|
>
|
2025-05-08 17:59:51 -05:00
|
|
|
<Outlet
|
|
|
|
|
context={{
|
|
|
|
|
iframeRef,
|
|
|
|
|
backupIframeRef,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2025-04-15 22:16:35 -05:00
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2025-05-08 17:59:51 -05:00
|
|
|
</Box>
|
2024-05-31 19:49:46 +05:30
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|