diff --git a/hooks/useLoadOnMount.ts b/hooks/useLoadOnMount.ts index 8c1a55830..5c5263b6a 100644 --- a/hooks/useLoadOnMount.ts +++ b/hooks/useLoadOnMount.ts @@ -2,13 +2,15 @@ import { useEffect } from 'react' import state from 'state' -export default function useLoadOnMount(roomId: string) { +export default function useLoadOnMount(roomId?: string) { useEffect(() => { const fonts = (document as any).fonts fonts.load('12px Verveine Regular', 'Fonts are loaded!').then(() => { state.send('MOUNTED') - state.send('RT_LOADED_ROOM', { id: roomId }) + if (roomId !== undefined) { + state.send('RT_LOADED_ROOM', { id: roomId }) + } }) return () => { diff --git a/state/state.ts b/state/state.ts index f5cf4ff44..d075ff3d6 100644 --- a/state/state.ts +++ b/state/state.ts @@ -163,10 +163,10 @@ const state = createState({ }, on: { // Network-Related - // RT_LOADED_ROOM: [ - // 'clearRoom', - // { if: 'hasRoom', do: ['resetDocumentState', 'connectToRoom'] }, - // ], + RT_LOADED_ROOM: [ + 'clearRoom', + { if: 'hasRoom', do: ['resetDocumentState', 'connectToRoom'] }, + ], // RT_UNLOADED_ROOM: ['clearRoom', 'resetDocumentState'], // RT_DISCONNECTED_ROOM: ['clearRoom', 'resetDocumentState'], // RT_CREATED_SHAPE: 'addRtShape',