mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-06 15:30:27 +03:00
Remove unused imports and restructure to support being parent to clientlayout
This commit is contained in:
parent
a690dbd2ca
commit
6714300779
1 changed files with 61 additions and 75 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import React, { useEffect, useMemo, useRef } from 'react';
|
||||
import React, { createContext, ReactNode, useEffect, useMemo, useRef } from 'react';
|
||||
import { logger } from 'matrix-js-sdk/lib/logger';
|
||||
import { ClientWidgetApi, IWidgetApiRequest } from 'matrix-widget-api';
|
||||
import { ClientWidgetApi } from 'matrix-widget-api';
|
||||
import { Box } from 'folds';
|
||||
import { Outlet, useParams } from 'react-router-dom';
|
||||
import { useCallState } from '../client/CallProvider';
|
||||
import {
|
||||
createVirtualWidget,
|
||||
|
|
@ -10,49 +11,38 @@ import {
|
|||
getWidgetUrl,
|
||||
} from '../../features/room/SmallWidget';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { RoomViewHeader } from '../../features/room/RoomViewHeader';
|
||||
import { Page, PageRoot } from '../../components/page';
|
||||
import { RouteSpaceProvider, Space, SpaceRouteRoomProvider } from '../client/space';
|
||||
import { MobileFriendlyPageNav } from '../MobileFriendly';
|
||||
import { SPACE_PATH } from '../paths';
|
||||
import { PowerLevelsContextProvider, usePowerLevels } from '../../hooks/usePowerLevels';
|
||||
import { useSelectedRoom } from '../../hooks/router/useSelectedRoom';
|
||||
import { useClientConfig } from '../../hooks/useClientConfig';
|
||||
import { RoomView } from '../../features/room/RoomView';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { PowerLevelsContainer } from './PowerLevelsContainer';
|
||||
import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize';
|
||||
|
||||
interface PersistentCallContainerProps {
|
||||
isVisible: boolean;
|
||||
viewedRoomId: string;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function PersistentCallContainer({
|
||||
isVisible,
|
||||
viewedRoomId,
|
||||
iframeRef,
|
||||
widgetApiRef,
|
||||
smallWidgetRef,
|
||||
backupIframeRef,
|
||||
backupWidgetApiRef,
|
||||
backupSmallWidgetRef,
|
||||
}: PersistentCallContainerProps) {
|
||||
export const RefContext = createContext(null);
|
||||
|
||||
export function PersistentCallContainer({ children }: PersistentCallContainerProps) {
|
||||
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 {
|
||||
activeCallRoomId,
|
||||
isChatOpen,
|
||||
isCallActive,
|
||||
isPrimaryIframe,
|
||||
setActiveCallRoomId,
|
||||
registerActiveClientWidgetApi,
|
||||
} = useCallState();
|
||||
const { eventId } = useParams();
|
||||
const mx = useMatrixClient();
|
||||
const roomId = useSelectedRoom();
|
||||
const clientConfig = useClientConfig();
|
||||
const room = mx.getRoom(roomId) ?? null;
|
||||
const screenSize = useScreenSizeContext();
|
||||
const isMobile = screenSize === ScreenSize.Mobile;
|
||||
const { roomIdOrAlias: viewedRoomId } = useParams();
|
||||
const isViewingActiveCall = useMemo(
|
||||
() => activeCallRoomId !== null && activeCallRoomId === viewedRoomId,
|
||||
[activeCallRoomId, viewedRoomId]
|
||||
|
|
@ -164,15 +154,9 @@ export function PersistentCallContainer({
|
|||
setupWidget(backupWidgetApiRef, backupSmallWidgetRef, backupIframeRef, false);
|
||||
});
|
||||
|
||||
const containerStyle: React.CSSProperties = {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
display: isVisible ? 'flex' : 'none',
|
||||
flexDirection: 'row',
|
||||
};
|
||||
|
||||
return (
|
||||
<Box direction="Row" grow="Yes" style={{ height: '0%', width: '0%' }}>
|
||||
<RefContext.Provider value={{ iframeRef, backupIframeRef }}>
|
||||
<Box grow="No">
|
||||
<Box
|
||||
direction="Column"
|
||||
style={{
|
||||
|
|
@ -195,7 +179,7 @@ export function PersistentCallContainer({
|
|||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
display: isPrimaryIframe || isViewingActiveCall ? 'flex' : 'none',
|
||||
display: isPrimaryIframe || isViewingActiveCall ? 'none' : 'none',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
border: 'none',
|
||||
|
|
@ -225,5 +209,7 @@ export function PersistentCallContainer({
|
|||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
{children}
|
||||
</RefContext.Provider>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue