fix(canvas): move ensureStoreIsUsable() to AFTER snapshot load — loadSnapshot() overwrites TLINSTANCE before it could be pre-initialized
Some checks failed
app-ci-deploy / test-build-deploy (push) Has been cancelled
Some checks failed
app-ci-deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
parent
ba829be8e9
commit
6cba932146
@ -98,9 +98,6 @@ export default function SinglePlayerPage() {
|
||||
shapeUtils: allShapeUtils,
|
||||
bindingUtils: allBindingUtils
|
||||
});
|
||||
// Pre-initialize tldraw's required records (TLINSTANCE, page, cameras)
|
||||
// so computed signals that read currentPageId don't crash before Editor construction completes
|
||||
(newStore as unknown as { ensureStoreIsUsable(): void }).ensureStoreIsUsable();
|
||||
|
||||
const snapSvc = new NavigationSnapshotService(newStore, editorRef.current || undefined);
|
||||
if (accessToken) snapSvc.setAccessToken(accessToken);
|
||||
@ -127,6 +124,10 @@ export default function SinglePlayerPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
// After snapshot loading (which may overwrite or clear store records),
|
||||
// ensure TLINSTANCE + page + cameras exist so tldraw never crashes on empty/corrupt store
|
||||
(newStore as unknown as { ensureStoreIsUsable(): void }).ensureStoreIsUsable();
|
||||
|
||||
let debounce: ReturnType<typeof setTimeout> | null = null;
|
||||
newStore.listen(() => {
|
||||
if (!snapshotServiceRef.current?.getCurrentNodePath()) return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user