From d0ce2d2597049155afa537cc3fe5340384cdb915 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Tue, 4 Mar 2025 17:40:13 -0500 Subject: [PATCH] [Cleanup] Refactor widget construction (#2861) --- src/services/litegraphService.ts | 34 ++++++++++---------------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/services/litegraphService.ts b/src/services/litegraphService.ts index cfa5affaf..bc9c9fd6a 100644 --- a/src/services/litegraphService.ts +++ b/src/services/litegraphService.ts @@ -59,33 +59,20 @@ export const useLitegraphService = () => { const inputType = inputSpec.type const nameKey = `nodeDefs.${normalizeI18nKey(nodeDef.name)}.inputs.${normalizeI18nKey(inputName)}.name` - let widgetCreated = true const widgetType = app.getWidgetType( [inputType, inputSpec], inputName ) if (widgetType) { - if (widgetType === 'COMBO') { - Object.assign( - config, - app.widgets.COMBO( - this, - inputName, - [inputType, inputSpec], - app - ) || {} - ) - } else { - Object.assign( - config, - app.widgets[widgetType]( - this, - inputName, - [inputType, inputSpec], - app - ) || {} - ) - } + Object.assign( + config, + app.widgets[widgetType]( + this, + inputName, + [inputType, inputSpec], + app + ) ?? {} + ) if (config.widget) { const fallback = config.widget.label ?? inputName config.widget.label = st(nameKey, fallback) @@ -100,10 +87,9 @@ export const useLitegraphService = () => { ...shapeOptions, localized_name: st(nameKey, inputName) }) - widgetCreated = false } - if (widgetCreated && config?.widget) { + if (widgetType && config?.widget) { config.widget.options ??= {} if (inputSpec.isOptional) { config.widget.options.inputIsOptional = true