forked from github/cinny
update client layout to funnel outlet the iframes for the call container
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import React, { ReactNode, useMemo } from 'react';
|
import React, { ReactNode, useMemo, useRef } from 'react';
|
||||||
import { Box } from 'folds';
|
import { Box } from 'folds';
|
||||||
import { useParams } from 'react-router-dom';
|
import { Outlet, useParams } from 'react-router-dom';
|
||||||
import { useCallState } from './CallProvider';
|
import { useCallState } from './CallProvider';
|
||||||
import { PersistentCallContainer } from '../call/PersistentCallContainer';
|
import { PersistentCallContainer } from '../call/PersistentCallContainer';
|
||||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
import { ClientWidgetApi } from 'matrix-widget-api';
|
||||||
|
import { SmallWidget } from '../../features/room/SmallWidget';
|
||||||
|
|
||||||
type ClientLayoutProps = {
|
type ClientLayoutProps = {
|
||||||
nav: ReactNode;
|
nav: ReactNode;
|
||||||
@@ -11,6 +13,13 @@ type ClientLayoutProps = {
|
|||||||
};
|
};
|
||||||
export function ClientLayout({ nav, children }: ClientLayoutProps) {
|
export function ClientLayout({ nav, children }: ClientLayoutProps) {
|
||||||
const { activeCallRoomId } = useCallState();
|
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);
|
||||||
const { roomIdOrAlias: viewedRoomId } = useParams();
|
const { roomIdOrAlias: viewedRoomId } = useParams();
|
||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
const isCall = mx.getRoom(viewedRoomId)?.isCallRoom();
|
const isCall = mx.getRoom(viewedRoomId)?.isCallRoom();
|
||||||
@@ -22,21 +31,38 @@ export function ClientLayout({ nav, children }: ClientLayoutProps) {
|
|||||||
</Box>
|
</Box>
|
||||||
<Box grow="Yes" direction="Column" style={{ position: 'relative', overflowY: 'auto' }}>
|
<Box grow="Yes" direction="Column" style={{ position: 'relative', overflowY: 'auto' }}>
|
||||||
<Box grow="Yes" style={{ position: 'relative' }}>
|
<Box grow="Yes" style={{ position: 'relative' }}>
|
||||||
|
<PersistentCallContainer
|
||||||
|
isVisible={false}
|
||||||
|
viewedRoomId={viewedRoomId}
|
||||||
|
iframeRef={iframeRef}
|
||||||
|
widgetApiRef={widgetApiRef}
|
||||||
|
smallWidgetRef={smallWidgetRef}
|
||||||
|
backupIframeRef={backupIframeRef}
|
||||||
|
backupWidgetApiRef={backupWidgetApiRef}
|
||||||
|
backupSmallWidgetRef={backupSmallWidgetRef}
|
||||||
|
/>
|
||||||
<Box
|
<Box
|
||||||
grow="Yes"
|
grow="Yes"
|
||||||
style={{
|
style={{
|
||||||
display: isCall ? 'none' : 'flex',
|
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
}}
|
}}
|
||||||
className="outlet-wrapper"
|
className="outlet-wrapper"
|
||||||
>
|
>
|
||||||
{children}
|
<Outlet
|
||||||
|
context={{
|
||||||
|
iframeRef,
|
||||||
|
widgetApiRef,
|
||||||
|
smallWidgetRef,
|
||||||
|
backupIframeRef,
|
||||||
|
backupWidgetApiRef,
|
||||||
|
backupSmallWidgetRef,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<PersistentCallContainer isVisible={isCall} viewedRoomId={viewedRoomId} />
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>{' '}
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user