Files
cinny/src/app/pages/client/ClientLayout.tsx
T

64 lines
2.2 KiB
TypeScript
Raw Normal View History

import React, { ReactNode, useMemo, useRef } from 'react';
import { Box } from 'folds';
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';
import { ClientWidgetApi } from 'matrix-widget-api';
import { SmallWidget } from '../../features/room/SmallWidget';
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();
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();
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' }}>
<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"
>
<Outlet
context={{
iframeRef,
backupIframeRef,
}}
/>
2025-04-15 22:16:35 -05:00
</Box>
</Box>
</Box>
</Box>
);
}