Merge pull request #160 from melMass/fix/set-alerts

fix: 🐛 simplify set/get alerts
This commit is contained in:
Jukka Seppänen 2024-12-23 19:37:30 +02:00 committed by GitHub
commit 7a190ce8c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,16 +28,16 @@ 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) {
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 +122,7 @@ app.registerExtension({
setColorAndBgColor.call(this, type);
}
} else {
alert("Error: Set node input undefined. Most likely you're missing custom nodes");
showAlert("node input undefined.")
}
}
if (link_info && node.graph && slotType == 2 && isChangeConnect) {
@ -134,7 +134,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 +485,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);
}
}