fix: 🐛 simplify set/get alerts

Now use the builtin toast api
This commit is contained in:
Mel Massadian 2024-12-23 18:24:54 +01:00
parent cdbd38213f
commit 3c6bb87083
No known key found for this signature in database
GPG Key ID: 1DFF0E9F71C7C85A

View File

@ -28,16 +28,17 @@ function setColorAndBgColor(type) {
this.bgcolor = colors.bgcolor;
}
}
let isAlertShown = false;
let disablePrefix = app.ui.settings.getSettingValue("KJNodes.disablePrefix")
const LGraphNode = LiteGraph.LGraphNode
function showAlertWithThrottle(message, delay) {
if (!isAlertShown) {
isAlertShown = true;
alert(message);
setTimeout(() => isAlertShown = false, delay);
}
function showAlert(message) {
message = message || "Set node input undefined."
app.extensionManager.toast.add({
severity: 'warn',
summary: "KJ Get/Set",
detail: `${message}. Most likely you're missing custom nodes`,
life: 5000,
})
}
app.registerExtension({
name: "SetNode",
@ -122,7 +123,7 @@ app.registerExtension({
setColorAndBgColor.call(this, type);
}
} else {
alert("Error: Set node input undefined. Most likely you're missing custom nodes");
showAlert("missing link info")
}
}
if (link_info && node.graph && slotType == 2 && isChangeConnect) {
@ -134,7 +135,7 @@ app.registerExtension({
this.outputs[0].type = type;
this.outputs[0].name = type;
} else {
alert("Error: Get Set node output undefined. Most likely you're missing custom nodes");
showAlert('node output undefined');
}
}
@ -485,7 +486,7 @@ app.registerExtension({
return link;
} else {
const errorMessage = "No SetNode found for " + this.widgets[0].value + "(" + this.type + ")";
showAlertWithThrottle(errorMessage, 5000);
showAlert(errorMessage);
//throw new Error(errorMessage);
}
}