From e5abf765bdc12b852ab816224decd42b1ae55a95 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Tue, 1 Apr 2025 11:31:28 -0400 Subject: [PATCH] [Performance] Avoid per-frame workflow persistence (#3301) --- src/composables/useWorkflowPersistence.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/composables/useWorkflowPersistence.ts b/src/composables/useWorkflowPersistence.ts index c8dbc3eeaa..7f14352f5b 100644 --- a/src/composables/useWorkflowPersistence.ts +++ b/src/composables/useWorkflowPersistence.ts @@ -1,4 +1,4 @@ -import { computed, watch, watchEffect } from 'vue' +import { computed, watch } from 'vue' import { api } from '@/scripts/api' import { app as comfyApp } from '@/scripts/app' @@ -70,15 +70,16 @@ export function useWorkflowPersistence() { } // Setup watchers - watchEffect(() => { - if (workflowStore.activeWorkflow) { - const workflow = workflowStore.activeWorkflow - setStorageValue('Comfy.PreviousWorkflow', workflow.key) + watch( + () => workflowStore.activeWorkflow, + (activeWorkflow) => { + if (!activeWorkflow) return + setStorageValue('Comfy.PreviousWorkflow', activeWorkflow.key) // When the activeWorkflow changes, the graph has already been loaded. // Saving the current state of the graph to the localStorage. persistCurrentWorkflow() } - }) + ) api.addEventListener('graphChanged', persistCurrentWorkflow) // Restore workflow tabs states