mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-24 08:44:06 +00:00
Add refresh button to remote (lazy) widgets (#2494)
This commit is contained in:
@@ -281,7 +281,13 @@ export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {
|
||||
}
|
||||
|
||||
if (remote) {
|
||||
const remoteWidget = useRemoteWidget(inputData)
|
||||
const remoteWidget = useRemoteWidget({
|
||||
inputData,
|
||||
defaultValue,
|
||||
node,
|
||||
widget: res.widget
|
||||
})
|
||||
if (remote.refresh_button) remoteWidget.addRefreshButton()
|
||||
|
||||
const origOptions = res.widget.options
|
||||
res.widget.options = new Proxy(
|
||||
@@ -289,22 +295,7 @@ export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {
|
||||
{
|
||||
get(target, prop: string | symbol) {
|
||||
if (prop !== 'values') return target[prop]
|
||||
|
||||
remoteWidget.fetchOptions().then((options) => {
|
||||
if (!options || !options.length) return
|
||||
|
||||
const isUninitialized =
|
||||
res.widget.value === remoteWidget.defaultValue &&
|
||||
!res.widget.options.values?.includes(remoteWidget.defaultValue)
|
||||
if (isUninitialized) {
|
||||
res.widget.value = options[0]
|
||||
res.widget.callback?.(options[0])
|
||||
node.graph?.setDirtyCanvas(true)
|
||||
}
|
||||
})
|
||||
|
||||
const current = remoteWidget.getCacheEntry()
|
||||
return current?.data || widgetStore.getDefaultValue(inputData)
|
||||
return remoteWidget.getValue()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user