fix(canvas): bypass localStoreService singleton — create store directly in effect to eliminate disposed-store reuse
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
6cba932146
commit
9a7cc86a75
@ -6,7 +6,8 @@ import {
|
|||||||
useTldrawUser,
|
useTldrawUser,
|
||||||
DEFAULT_SUPPORT_VIDEO_TYPES,
|
DEFAULT_SUPPORT_VIDEO_TYPES,
|
||||||
DEFAULT_SUPPORTED_IMAGE_TYPES,
|
DEFAULT_SUPPORTED_IMAGE_TYPES,
|
||||||
TLStore
|
TLStore,
|
||||||
|
createTLStore,
|
||||||
} from '@tldraw/tldraw';
|
} from '@tldraw/tldraw';
|
||||||
import { useTLDraw } from '../../contexts/TLDrawContext';
|
import { useTLDraw } from '../../contexts/TLDrawContext';
|
||||||
import { useAuth } from '../../contexts/AuthContext';
|
import { useAuth } from '../../contexts/AuthContext';
|
||||||
@ -93,10 +94,11 @@ export default function SinglePlayerPage() {
|
|||||||
const run = async () => {
|
const run = async () => {
|
||||||
try {
|
try {
|
||||||
setCanvasPhase('store-init');
|
setCanvasPhase('store-init');
|
||||||
const newStore = localStoreService.getStore({
|
// Create a fresh store directly — bypassing singleton to avoid disposed-store reuse issues
|
||||||
|
const newStore = createTLStore({
|
||||||
schema: customSchema,
|
schema: customSchema,
|
||||||
shapeUtils: allShapeUtils,
|
shapeUtils: allShapeUtils,
|
||||||
bindingUtils: allBindingUtils
|
bindingUtils: allBindingUtils,
|
||||||
});
|
});
|
||||||
|
|
||||||
const snapSvc = new NavigationSnapshotService(newStore, editorRef.current || undefined);
|
const snapSvc = new NavigationSnapshotService(newStore, editorRef.current || undefined);
|
||||||
@ -154,7 +156,6 @@ export default function SinglePlayerPage() {
|
|||||||
snapshotServiceRef.current = null;
|
snapshotServiceRef.current = null;
|
||||||
storeRef.current?.dispose();
|
storeRef.current?.dispose();
|
||||||
storeRef.current = null;
|
storeRef.current = null;
|
||||||
localStoreService.clearStore(); // reset singleton so next getStore() creates a fresh store
|
|
||||||
setStoreReady(false);
|
setStoreReady(false);
|
||||||
setCanvasPhase('idle');
|
setCanvasPhase('idle');
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user