Fix notification inputs

Instead of trying to manually find the widget values, pass the values to
the the frontend.

Fixes: #409
This commit is contained in:
Gremlation
2024-12-24 22:19:58 +08:00
parent d6657cc1f0
commit 9ab0910980
2 changed files with 5 additions and 7 deletions
+2 -2
View File
@@ -28,8 +28,8 @@ class SystemNotification:
def IS_CHANGED(self, **kwargs): def IS_CHANGED(self, **kwargs):
return float("NaN") return float("NaN")
def nop(self, any, **kwargs): def nop(self, any, message, mode):
return {"ui": {"a": []}, "result": (any,)} return {"ui": {"message": message, "mode": mode}, "result": (any,)}
NODE_CLASS_MAPPINGS = { NODE_CLASS_MAPPINGS = {
+3 -5
View File
@@ -22,12 +22,10 @@ app.registerExtension({
async beforeRegisterNodeDef(nodeType, nodeData, app) { async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === "SystemNotification|pysssss") { if (nodeData.name === "SystemNotification|pysssss") {
const onExecuted = nodeType.prototype.onExecuted; const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = async function () { nodeType.prototype.onExecuted = async function ({ message, mode }) {
onExecuted?.apply(this, arguments); onExecuted?.apply(this, arguments);
const mode = this.widgets.find((w) => w.name === "mode");
const message = this.widgets.find((w) => w.name === "message");
if (mode.value === "on empty queue") { if (mode === "on empty queue") {
if (app.ui.lastQueueSize !== 0) { if (app.ui.lastQueueSize !== 0) {
await new Promise((r) => setTimeout(r, 500)); await new Promise((r) => setTimeout(r, 500));
} }
@@ -36,7 +34,7 @@ app.registerExtension({
} }
} }
if (!notificationSetup()) return; if (!notificationSetup()) return;
const notification = new Notification("ComfyUI", { body: message.value ?? "Your notification has triggered." }); const notification = new Notification("ComfyUI", { body: message ?? "Your notification has triggered." });
}; };
const onNodeCreated = nodeType.prototype.onNodeCreated; const onNodeCreated = nodeType.prototype.onNodeCreated;