mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-04 04:30:04 +00:00
Implement proper invalidation on switch (#5383)
This commit is contained in:
@@ -410,6 +410,15 @@ class LayoutStoreImpl implements LayoutStore {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all slot layouts and their spatial index (O(1) operations)
|
||||
* Used when switching rendering modes (Vue ↔ LiteGraph)
|
||||
*/
|
||||
clearAllSlotLayouts(): void {
|
||||
this.slotLayouts.clear()
|
||||
this.slotSpatialIndex.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* Update reroute layout data
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,7 @@ import { layoutStore } from '@/renderer/core/layout/store/layoutStore'
|
||||
* Compute and register slot layouts for a node
|
||||
* @param node LiteGraph node to process
|
||||
*/
|
||||
function computeAndRegisterSlots(node: LGraphNode): void {
|
||||
export function computeAndRegisterSlots(node: LGraphNode): void {
|
||||
const nodeId = String(node.id)
|
||||
const nodeLayout = layoutStore.getNodeLayoutRef(nodeId).value
|
||||
|
||||
@@ -57,17 +57,18 @@ export function useSlotLayoutSync() {
|
||||
let restoreHandlers: (() => void) | null = null
|
||||
|
||||
/**
|
||||
* Start slot layout sync with full event-driven functionality
|
||||
* Attempt to start slot layout sync with full event-driven functionality
|
||||
* @param canvas LiteGraph canvas instance
|
||||
* @returns true if sync was actually started, false if early-returned
|
||||
*/
|
||||
function start(canvas: LGraphCanvas): void {
|
||||
function attemptStart(canvas: LGraphCanvas): boolean {
|
||||
// When Vue nodes are enabled, slot DOM registers exact positions.
|
||||
// Skip calculated registration to avoid conflicts.
|
||||
if (LiteGraph.vueNodesMode) {
|
||||
return
|
||||
return false
|
||||
}
|
||||
const graph = canvas?.graph
|
||||
if (!graph) return
|
||||
if (!graph) return false
|
||||
|
||||
// Initial registration for all nodes in the current graph
|
||||
for (const node of graph.nodes) {
|
||||
@@ -135,6 +136,8 @@ export function useSlotLayoutSync() {
|
||||
graph.onTrigger = origTrigger || undefined
|
||||
graph.onAfterChange = origAfterChange || undefined
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +160,7 @@ export function useSlotLayoutSync() {
|
||||
})
|
||||
|
||||
return {
|
||||
start,
|
||||
attemptStart,
|
||||
stop
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,6 +297,7 @@ export interface LayoutStore {
|
||||
deleteSlotLayout(key: string): void
|
||||
deleteNodeSlotLayouts(nodeId: NodeId): void
|
||||
deleteRerouteLayout(rerouteId: RerouteId): void
|
||||
clearAllSlotLayouts(): void
|
||||
|
||||
// Get layout data
|
||||
getLinkLayout(linkId: LinkId): LinkLayout | null
|
||||
|
||||
Reference in New Issue
Block a user