mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
refactor: add deactivate() and prepareForSave() to ChangeTracker
- deactivate(): unified freeze step combining captureCanvasState() + store(), called when a workflow goes inactive - prepareForSave(): save-path API that flushes canvas state only for the active workflow (no-op for inactive, whose state was frozen by deactivate)
This commit is contained in:
@@ -91,6 +91,26 @@ export class ChangeTracker {
|
||||
this.subgraphState = { navigation }
|
||||
}
|
||||
|
||||
/**
|
||||
* Freeze this tracker's state before the workflow goes inactive.
|
||||
* Captures the final canvas state + viewport/outputs.
|
||||
* Called exactly once when switching away from this workflow.
|
||||
*/
|
||||
deactivate() {
|
||||
this.captureCanvasState()
|
||||
this.store()
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure activeState is up-to-date for persistence.
|
||||
* Active workflow: flushes canvas → activeState.
|
||||
* Inactive workflow: no-op (activeState was frozen by deactivate()).
|
||||
*/
|
||||
prepareForSave() {
|
||||
const isActive = useWorkflowStore().activeWorkflow?.changeTracker === this
|
||||
if (isActive) this.captureCanvasState()
|
||||
}
|
||||
|
||||
restore() {
|
||||
if (this.ds) {
|
||||
app.canvas.ds.scale = this.ds.scale
|
||||
|
||||
Reference in New Issue
Block a user