import { useSync } from '@tldraw/sync' import { ReactNode, useEffect, useState } from 'react' import { useParams } from 'react-router-dom' import { Tldraw } from 'tldraw' import { getBookmarkPreview } from '../getBookmarkPreview' import { multiplayerAssetStore } from '../multiplayerAssetStore' export function Room() { const { roomId } = useParams<{ roomId: string }>() // Create a store connected to multiplayer. const store = useSync({ // We need to know the websockets URI... uri: `${window.location.origin}/api/connect/${roomId}`, // ...and how to handle static assets like images & videos assets: multiplayerAssetStore, }) return ( { // when the editor is ready, we need to register our bookmark unfurling service editor.registerExternalAssetHandler('url', getBookmarkPreview) }} /> ) } function RoomWrapper({ children, roomId }: { children: ReactNode; roomId?: string }) { const [didCopy, setDidCopy] = useState(false) useEffect(() => { if (!didCopy) return const timeout = setTimeout(() => setDidCopy(false), 3000) return () => clearTimeout(timeout) }, [didCopy]) return (
{roomId}
{children}
) } function WifiIcon() { return ( ) }