import i18next from 'i18next'; import React, { Suspense, useCallback, useRef } from 'react'; import { useSelector } from 'react-redux'; import { IReduxState } from '../../../app/types'; import { WHITEBOARD_UI_OPTIONS } from '../../constants'; import { getStorageBackendUrl } from '../../functions'; const LazyExcalidrawApp = React.lazy(async () => { const [ { ExcalidrawApp } ] = await Promise.all([ import(/* webpackChunkName: "excalidraw" */ '@jitsi/excalidraw'), import(/* webpackChunkName: "excalidraw" */ '@jitsi/excalidraw/index.css') ]); return { default: ExcalidrawApp }; }); /** * Whiteboard wrapper for mobile. * * @returns {JSX.Element} */ const WhiteboardWrapper = ({ className, collabDetails, collabServerUrl, localParticipantName }: { className?: string; collabDetails: { roomId: string; roomKey: string; }; collabServerUrl: string; localParticipantName: string; }) => { const excalidrawAPIRef = useRef(null); const collabAPIRef = useRef(null); const storageBackendUrl = useSelector(getStorageBackendUrl); const jwt = useSelector((state: IReduxState) => state['features/base/jwt']).jwt || ''; const getExcalidrawAPI = useCallback(excalidrawAPI => { if (excalidrawAPIRef.current) { return; } excalidrawAPIRef.current = excalidrawAPI; }, []); const getCollabAPI = useCallback(collabAPI => { if (collabAPIRef.current) { return; } collabAPIRef.current = collabAPI; collabAPIRef.current.setUsername(localParticipantName); }, [ localParticipantName ]); return (
); }; export default WhiteboardWrapper;