fix: add cleanup for graphChanged listener in useWorkflowPersistence (#4947)

This commit is contained in:
Christian Byrne
2025-08-12 12:27:04 -07:00
committed by GitHub
parent c42c9315f4
commit 24a386c766

View File

@@ -1,3 +1,4 @@
import { tryOnScopeDispose } from '@vueuse/core'
import { computed, watch } from 'vue'
import { api } from '@/scripts/api'
@@ -88,6 +89,11 @@ export function useWorkflowPersistence() {
)
api.addEventListener('graphChanged', persistCurrentWorkflow)
// Clean up event listener when component unmounts
tryOnScopeDispose(() => {
api.removeEventListener('graphChanged', persistCurrentWorkflow)
})
// Restore workflow tabs states
const openWorkflows = computed(() => workflowStore.openWorkflows)
const activeWorkflow = computed(() => workflowStore.activeWorkflow)