From b8d629248e19dc2c9abb326aa87daa06bbdeb3b2 Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Thu, 26 Oct 2023 19:21:44 -0500 Subject: [PATCH] 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. --- web/js/VHS.core.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/web/js/VHS.core.js b/web/js/VHS.core.js index 6a2504b..50be3f1 100644 --- a/web/js/VHS.core.js +++ b/web/js/VHS.core.js @@ -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"