mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
refactor: Extract isNodeEnabled helper to eliminate mode check duplication
Consolidate node enabled state checks into isNodeEnabled() helper function to improve code clarity and maintainability. Follows DRY principle.
This commit is contained in:
@@ -457,6 +457,14 @@ function getWidgetNames(node) {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isNodeEnabled(node) {
|
||||||
|
if (!node) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// ComfyUI node mode: 0 = Normal/Enabled, others = Always/Never/OnEvent
|
||||||
|
return node.mode === undefined || node.mode === 0;
|
||||||
|
}
|
||||||
|
|
||||||
function isAbsolutePath(path) {
|
function isAbsolutePath(path) {
|
||||||
if (typeof path !== 'string') {
|
if (typeof path !== 'string') {
|
||||||
return false;
|
return false;
|
||||||
@@ -507,10 +515,7 @@ export async function sendLoraToWorkflow(loraSyntax, replaceMode = false, syntax
|
|||||||
}
|
}
|
||||||
|
|
||||||
const loraNodes = filterRegistryNodes(registry.nodes, (node) => {
|
const loraNodes = filterRegistryNodes(registry.nodes, (node) => {
|
||||||
if (!node) {
|
if (!isNodeEnabled(node)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (node.mode !== undefined && node.mode !== 0) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (node.capabilities && typeof node.capabilities === 'object') {
|
if (node.capabilities && typeof node.capabilities === 'object') {
|
||||||
@@ -572,10 +577,7 @@ export async function sendModelPathToWorkflow(modelPath, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const targetNodes = filterRegistryNodes(registry.nodes, (node) => {
|
const targetNodes = filterRegistryNodes(registry.nodes, (node) => {
|
||||||
if (!node) {
|
if (!isNodeEnabled(node)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (node.mode !== undefined && node.mode !== 0) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const widgetNames = getWidgetNames(node);
|
const widgetNames = getWidgetNames(node);
|
||||||
|
|||||||
Reference in New Issue
Block a user