Add migratory code to prevent need for remove/add

While the new KV state storage should prevent the need for this in the
future and there's a degree of error checking, it would be particularly
poor optics for the system to break all existing workflows on release.

This adds a couple of migratory functions that carefully check and
manage the transitions for the two nodes that break.
This commit is contained in:
Austin Mroz
2023-10-26 19:29:59 -05:00
parent 3a6b9fb5c7
commit b8d629248e
+16
View File
@@ -57,6 +57,22 @@ function useKVState(nodeType) {
//This probably means it's an array and was already restored.
if (info?.widgets_values?.length != this.widgets.length) {
//Widget could not have restored properly
//First try a number of known migrations.
//This code hits only specific common cases and is deprecated
if(this.type == "VHS_LoadVideo" && info?.widgets_values?.length == 7) {
//custom_width, custom_height, preview added. Shift and load
this.widgets[3].value = 512;
this.widgets[4].value = 512;
this.widgets[5].value = info.widgets_values[3];
this.widgets[6].value = info.widgets_values[4];
this.widgets[7].value = info.widgets_values[5];
return
} else if (this.type == "VHS_VideoCombine" && info?.widgets_values?.length == 7) {
//the sync button was removed, but actual loading was not impacted
return
}
//Note if multiple node loads fail, only the latest error dialog displays
app.ui.dialog.show("Failed to restore node: " + this.title + "\nPlease remove and re-add it.")
this.bgcolor = "#C00"