Light up refreshed combo boxes

This commit is contained in:
space-nuko
2023-05-16 21:08:43 -05:00
parent 9f1da40385
commit 0626baba2e
5 changed files with 21 additions and 28 deletions

View File

@@ -1,6 +1,6 @@
import type IComfyInputSlot from "$lib/IComfyInputSlot";
import { BuiltInSlotType, LiteGraph, type INodeInputSlot, type LGraphNode, type SerializedLGraphNode, type SlotLayout } from "@litegraph-ts/core";
import { writable, type Writable } from "svelte/store";
import { get, writable, type Writable } from "svelte/store";
import ComboWidget from "$lib/widgets/ComboWidget.svelte";
import type { ComfyWidgetProperties } from "./ComfyWidgetNode";
@@ -39,11 +39,13 @@ export default class ComfyComboNode extends ComfyWidgetNode<string> {
// True if at least one combo box refresh has taken place
// Wait until the initial graph load for combo to be valid.
firstLoad: Writable<boolean>;
lightUp: Writable<boolean>;
valuesForCombo: Writable<any[] | null>; // Changed when the combo box has values.
constructor(name?: string) {
super(name, "A")
this.firstLoad = writable(false)
this.lightUp = writable(true)
this.valuesForCombo = writable(null)
}
@@ -53,11 +55,14 @@ export default class ComfyComboNode extends ComfyWidgetNode<string> {
}
}
formatValues(values: string[]) {
formatValues(values: string[], lightUp: boolean = false) {
if (values == null)
return;
const changed = this.properties.values != values;
this.properties.values = values;
if (lightUp && get(this.firstLoad) && changed)
this.lightUp.set(true)
let formatter: any;
if (this.properties.convertValueToLabelCode)