wait for the app to be ready and load docs
This commit is contained in:
parent
e984acbd30
commit
6079b3cb14
1 changed files with 10 additions and 8 deletions
|
@ -239,16 +239,18 @@ export function Tldraw({
|
|||
if (decodedPage.length === 0) return
|
||||
const state = JSON.parse(decodedPage) as Record<string, any>
|
||||
if (Object.keys(state).length) {
|
||||
if ('page' in state) {
|
||||
app.loadDocumentFromURL(state.page, state.pageState)
|
||||
} else {
|
||||
const nextDocument = state as TDDocument
|
||||
if (nextDocument.id === app.document.id) {
|
||||
app.updateDocument(nextDocument)
|
||||
app.ready.then(() => {
|
||||
if ('page' in state) {
|
||||
app.loadDocumentFromURL(state.page, state.pageState)
|
||||
} else {
|
||||
app.loadDocument(nextDocument)
|
||||
const nextDocument = state as TDDocument
|
||||
if (nextDocument.id === app.document.id) {
|
||||
app.updateDocument(nextDocument)
|
||||
} else {
|
||||
app.loadDocument(nextDocument)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}, [app, decodedPage])
|
||||
|
||||
|
|
Loading…
Reference in a new issue