Files
wehub-resource-sync c48612c494
CI / E2E Tests (push) Has been cancelled
CI / Lint, Typecheck & Unit Tests (push) Has been cancelled
Docs Build / Build docs site (push) Has been cancelled
Publish @openmaic packages / Build, validate & publish (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:03:23 +08:00

23 lines
1022 B
TypeScript

'use client';
/**
* Apply a scene patch to the stage store while keeping the OPEN slide edit
* session in lockstep. Shared by both the `regenerate_scene` apply path and the
* "restore previous" button — without reseeding the open session, the canvas
* keeps rendering its stale `history.present` and the next edit clobbers the
* applied change.
*/
import { useStageStore } from '@/lib/store/stage';
import { useSlideEditSession } from '@/components/edit/surfaces/slide/slide-edit-session';
import type { ScenePatch, SlideContent } from '@/lib/types/stage';
/** Apply a scene patch to the stage store and keep the OPEN slide edit session
* in lockstep (else the canvas renders stale history and clobbers the change). */
export function applyScenePatchInSync(sceneId: string, patch: ScenePatch): void {
useStageStore.getState().updateScene(sceneId, patch);
const es = useSlideEditSession.getState();
if (patch.content && es.sceneId === sceneId) {
es.seed(sceneId, patch.content as SlideContent);
}
}