Potentially fixes bug when roomId changes
This commit is contained in:
parent
5334f41e1d
commit
be359e6406
2 changed files with 11 additions and 7 deletions
|
@ -3,12 +3,12 @@ import { useEffect } from 'react'
|
||||||
import state from 'state'
|
import state from 'state'
|
||||||
import coopState from 'state/coop/coop-state'
|
import coopState from 'state/coop/coop-state'
|
||||||
|
|
||||||
export default function useLoadOnMount(roomId: string = undefined) {
|
export default function useLoadOnMount(roomId?: string) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if ('fonts' in document) {
|
if ('fonts' in document) {
|
||||||
const fonts = (document as any).fonts
|
const fonts = (document as any).fonts
|
||||||
fonts.load('12px Verveine Regular', 'Fonts are loaded!').then(() => {
|
fonts.load('12px Verveine Regular', 'Fonts are loaded!').then(() => {
|
||||||
state.send('MOUNTED')
|
state.send('MOUNTED', { roomId })
|
||||||
|
|
||||||
if (roomId !== undefined) {
|
if (roomId !== undefined) {
|
||||||
state.send('RT_LOADED_ROOM', { id: roomId })
|
state.send('RT_LOADED_ROOM', { id: roomId })
|
||||||
|
@ -20,7 +20,7 @@ export default function useLoadOnMount(roomId: string = undefined) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
state.send('UNMOUNTED').send('RT_UNLOADED_ROOM', { id: roomId })
|
state.send('UNMOUNTED', { roomId })
|
||||||
coopState.send('LEFT_ROOM', { id: roomId })
|
coopState.send('LEFT_ROOM', { id: roomId })
|
||||||
}
|
}
|
||||||
}, [roomId])
|
}, [roomId])
|
||||||
|
|
|
@ -158,10 +158,11 @@ const state = createState({
|
||||||
states: {
|
states: {
|
||||||
loading: {
|
loading: {
|
||||||
on: {
|
on: {
|
||||||
MOUNTED: {
|
MOUNTED: [
|
||||||
do: ['resetHistory', 'restoredPreviousDocument'],
|
'resetHistory',
|
||||||
to: 'ready',
|
{ unless: 'hasRoomId', do: 'restoredPreviousDocument' },
|
||||||
},
|
{ to: 'ready' },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ready: {
|
ready: {
|
||||||
|
@ -1124,6 +1125,9 @@ const state = createState({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
conditions: {
|
conditions: {
|
||||||
|
hasRoomId(data, payload: { roomId?: string }) {
|
||||||
|
return payload?.roomId !== undefined
|
||||||
|
},
|
||||||
isSimulating() {
|
isSimulating() {
|
||||||
return logger.isSimulating
|
return logger.isSimulating
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue