Skip to content
Open
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
28 changes: 28 additions & 0 deletions src_web/comfyui/power_lora_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type {
SerializedLGraphNode,
Vector2,
AdjustedMouseEvent,
IContextMenuOptions,
ContextMenu,
} from "typings/litegraph.js";
import type { ComfyObjectInfo, ComfyNodeConstructor } from "typings/comfy.js";
import { RgthreeBaseServerNode } from "./base_node.js";
Expand Down Expand Up @@ -116,6 +118,32 @@ class RgthreePowerLoraLoader extends RgthreeBaseServerNode {
this.setDirtyCanvas(true, true);
}

override getExtraMenuOptions(canvas: LGraphCanvas, options: ContextMenuItem[]): void {
super.getExtraMenuOptions?.apply(this, [...arguments] as any);
const fetchInfoMenuItem = {
content: "Fetch info for all LoRAs",
callback: (
_value: ContextMenuItem,
_options: IContextMenuOptions,
_event: MouseEvent,
_parentMenu: ContextMenu | undefined,
_node: TLGraphNode,
) => {
const loraWidgets: PowerLoraLoaderWidget[] = this.widgets
.filter((widget): widget is PowerLoraLoaderWidget => widget instanceof PowerLoraLoaderWidget);
const refreshPromises = loraWidgets
.map(widget => widget.value.lora)
.filter((file): file is string => file !== null)
.map((file) => MODEL_INFO_SERVICE.refreshLora(file));
Promise.all(refreshPromises).then((loraInfo) => {
// Silently succeeds or fails. Probably want a better notification than `alert`
// alert(`LoRA info refreshed. ${loraInfo.length} checked`);
});
},
};
options.splice(options.length - 1, 0, fetchInfoMenuItem);
}

/** Adds a new lora widget in the proper slot. */
private addNewLoraWidget(lora?: string) {
this.loraWidgetsCounter++;
Expand Down
18 changes: 18 additions & 0 deletions web/comfyui/power_lora_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ class RgthreePowerLoraLoader extends RgthreeBaseServerNode {
this.size[1] = Math.max(this.size[1], computed[1]);
this.setDirtyCanvas(true, true);
}
getExtraMenuOptions(canvas, options) {
var _b;
(_b = super.getExtraMenuOptions) === null || _b === void 0 ? void 0 : _b.apply(this, [...arguments]);
const fetchInfoMenuItem = {
content: "Fetch info for all LoRAs",
callback: (_value, _options, _event, _parentMenu, _node) => {
const loraWidgets = this.widgets
.filter((widget) => widget instanceof PowerLoraLoaderWidget);
const refreshPromises = loraWidgets
.map(widget => widget.value.lora)
.filter((file) => file !== null)
.map((file) => MODEL_INFO_SERVICE.refreshLora(file));
Promise.all(refreshPromises).then((loraInfo) => {
});
},
};
options.splice(options.length - 1, 0, fetchInfoMenuItem);
}
addNewLoraWidget(lora) {
this.loraWidgetsCounter++;
const widget = this.addCustomWidget(new PowerLoraLoaderWidget("lora_" + this.loraWidgetsCounter));
Expand Down