Allow for room loading

This commit is contained in:
Steve Ruiz 2021-06-30 21:33:30 +01:00
parent 21c15e5fae
commit 778daeb8ff
2 changed files with 8 additions and 6 deletions

View file

@ -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 () => {

View file

@ -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',