mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-19 14:30:07 +00:00
[Performance] Avoid per-frame workflow persistence (#3301)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user