mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 10:59:53 +00:00
refactor(GraphCanvas): Phase 3 - code organization fixes
- Consolidate two Vue node lifecycle reset watchers into one - Remove duplicate useVueFeatureFlags() call - Cache store references at top level instead of calling inside callbacks Amp-Thread-ID: https://ampcode.com/threads/T-019bf963-9130-77df-bacc-7d4b1c5cae31 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -223,13 +223,13 @@ const handleVueNodeLifecycleReset = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => canvasStore.currentGraph, handleVueNodeLifecycleReset)
|
||||
const workflowStore = useWorkflowStore()
|
||||
|
||||
watch(
|
||||
() => canvasStore.isInSubgraph,
|
||||
async (newValue, oldValue) => {
|
||||
if (oldValue && !newValue) {
|
||||
useWorkflowStore().updateActiveGraph()
|
||||
() => [canvasStore.currentGraph, canvasStore.isInSubgraph] as const,
|
||||
async ([_graph, isInSubgraph], [_prevGraph, wasInSubgraph]) => {
|
||||
if (wasInSubgraph && !isInSubgraph) {
|
||||
workflowStore.updateActiveGraph()
|
||||
}
|
||||
await handleVueNodeLifecycleReset()
|
||||
}
|
||||
@@ -332,7 +332,6 @@ watch(
|
||||
[executionStore.nodeLocationProgressStates, canvasStore.canvas] as const,
|
||||
([nodeLocationProgressStates, canvas]) => {
|
||||
if (!canvas?.graph) return
|
||||
const workflowStore = useWorkflowStore()
|
||||
for (const node of canvas.graph.nodes) {
|
||||
const nodeLocatorId = workflowStore.nodeIdToNodeLocatorId(node.id)
|
||||
const progressState = nodeLocationProgressStates[nodeLocatorId]
|
||||
@@ -399,6 +398,7 @@ useEventListener(
|
||||
|
||||
const comfyAppReady = ref(false)
|
||||
const workflowPersistence = useWorkflowPersistence()
|
||||
const commandStore = useCommandStore()
|
||||
const { flags } = useFeatureFlags()
|
||||
// Set up invite loader during setup phase so useRoute/useRouter work correctly
|
||||
const inviteUrlLoader = isCloud ? useInviteUrlLoader() : null
|
||||
@@ -408,7 +408,6 @@ useNodeBadge()
|
||||
|
||||
useGlobalLitegraph()
|
||||
useContextMenuTranslation()
|
||||
useVueFeatureFlags()
|
||||
useCopy()
|
||||
usePaste()
|
||||
useWorkflowAutoSave()
|
||||
@@ -427,16 +426,16 @@ watch(
|
||||
newUserService().initializeIfNewUser(settingStore)
|
||||
])
|
||||
if (runId !== localeWatcherRunId) return
|
||||
await useCommandStore().execute('Comfy.RefreshNodeDefinitions')
|
||||
await commandStore.execute('Comfy.RefreshNodeDefinitions')
|
||||
if (runId !== localeWatcherRunId) return
|
||||
await useWorkflowService().reloadCurrentWorkflow()
|
||||
}
|
||||
)
|
||||
useEventListener(
|
||||
() => useCanvasStore().canvas?.canvas,
|
||||
() => canvasStore.canvas?.canvas,
|
||||
'litegraph:set-graph',
|
||||
() => {
|
||||
useWorkflowStore().updateActiveGraph()
|
||||
workflowStore.updateActiveGraph()
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user