Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Replace magic numbers with LGraphEventMode" #1810

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/hooks/coreCommandHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { useWorkspaceStore } from '@/stores/workspaceStore'
import { LGraphGroup } from '@comfyorg/litegraph'
import { LiteGraph } from '@comfyorg/litegraph'
import { LGraphNode } from '@comfyorg/litegraph'
import { LGraphEventMode } from '@comfyorg/litegraph/dist/types/globalEnums'

export function useCoreCommands(): ComfyCommand[] {
const getTracker = () => useWorkflowStore()?.activeWorkflow?.changeTracker
Expand All @@ -33,10 +32,10 @@ export function useCoreCommands(): ComfyCommand[] {
return result
}

const toggleSelectedNodesMode = (mode: LGraphEventMode) => {
const toggleSelectedNodesMode = (mode: number) => {
getSelectedNodes().forEach((node) => {
if (node.mode === mode) {
node.mode = LGraphEventMode.ALWAYS
node.mode = 0 // always
} else {
node.mode = mode
}
Expand Down Expand Up @@ -341,7 +340,7 @@ export function useCoreCommands(): ComfyCommand[] {
label: 'Mute/Unmute Selected Nodes',
versionAdded: '1.3.11',
function: () => {
toggleSelectedNodesMode(LGraphEventMode.NEVER)
toggleSelectedNodesMode(2) // muted
}
},
{
Expand All @@ -350,7 +349,7 @@ export function useCoreCommands(): ComfyCommand[] {
label: 'Bypass/Unbypass Selected Nodes',
versionAdded: '1.3.11',
function: () => {
toggleSelectedNodesMode(LGraphEventMode.BYPASS)
toggleSelectedNodesMode(4) // bypassed
}
},
{
Expand Down
29 changes: 11 additions & 18 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ import { type IBaseWidget } from '@comfyorg/litegraph/dist/types/widgets'
import { workflowService } from '@/services/workflowService'
import { useWidgetStore } from '@/stores/widgetStore'
import { deserialiseAndCreate } from '@/extensions/core/vintageClipboard'
import { LGraphEventMode } from '@comfyorg/litegraph/dist/types/globalEnums'

export const ANIM_PREVIEW_WIDGET = '$$comfy_animation_preview'

Expand Down Expand Up @@ -586,9 +585,8 @@ export class ComfyApp {
options.push({
content: 'Bypass',
callback: (obj) => {
if (this.mode === LGraphEventMode.BYPASS)
this.mode = LGraphEventMode.ALWAYS
else this.mode = LGraphEventMode.BYPASS
if (this.mode === 4) this.mode = 0
else this.mode = 4
this.graph.change()
}
})
Expand Down Expand Up @@ -1479,12 +1477,15 @@ export class ComfyApp {
const old_color = node.color
const old_bgcolor = node.bgcolor

if (node.mode === LGraphEventMode.NEVER) {
if (node.mode === 2) {
// never
this.editor_alpha = 0.4
}

// ComfyUI's custom node mode enum value 4 => bypass/never.
let bgColor: string
if (node.mode === LGraphEventMode.BYPASS) {
if (node.mode === 4) {
// never
bgColor = app.bypassBgColor
this.editor_alpha = 0.2
} else {
Expand Down Expand Up @@ -2303,9 +2304,7 @@ export class ComfyApp {
const output = {}
// Process nodes in order of execution
for (const outerNode of graph.computeExecutionOrder(false)) {
const skipNode =
outerNode.mode === LGraphEventMode.NEVER ||
outerNode.mode === LGraphEventMode.BYPASS
const skipNode = outerNode.mode === 2 || outerNode.mode === 4
const innerNodes =
!skipNode && outerNode.getInnerNodes
? outerNode.getInnerNodes()
Expand All @@ -2315,10 +2314,7 @@ export class ComfyApp {
continue
}

if (
node.mode === LGraphEventMode.NEVER ||
node.mode === LGraphEventMode.BYPASS
) {
if (node.mode === 2 || node.mode === 4) {
// Don't serialize muted nodes
continue
}
Expand All @@ -2343,10 +2339,7 @@ export class ComfyApp {
let parent = node.getInputNode(i)
if (parent) {
let link = node.getInputLink(i)
while (
parent.mode === LGraphEventMode.BYPASS ||
parent.isVirtualNode
) {
while (parent.mode === 4 || parent.isVirtualNode) {
let found = false
if (parent.isVirtualNode) {
link = parent.getInputLink(link.origin_slot)
Expand All @@ -2356,7 +2349,7 @@ export class ComfyApp {
found = true
}
}
} else if (link && parent.mode === LGraphEventMode.BYPASS) {
} else if (link && parent.mode === 4) {
let all_inputs = [link.origin_slot]
if (parent.inputs) {
all_inputs = all_inputs.concat(Object.keys(parent.inputs))
Expand Down
Loading