From a79be1e3ef3f2144f975575c6a4751a963bd9574 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Wed, 24 Apr 2024 17:13:44 +0100 Subject: [PATCH] Removed autoBakePause flag and statechange trigger in InputWaiter.set() as they are redundant. --- src/web/App.mjs | 23 ++--------------------- src/web/waiters/InputWaiter.mjs | 7 ++----- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/web/App.mjs b/src/web/App.mjs index e86e7e3b..3ebfe1be 100755 --- a/src/web/App.mjs +++ b/src/web/App.mjs @@ -39,7 +39,6 @@ class App { this.baking = false; this.autoBake_ = false; - this.autoBakePause = false; this.progress = 0; this.ingId = 0; @@ -155,11 +154,6 @@ class App { * Runs Auto Bake if it is set. */ autoBake() { - // If autoBakePause is set, we are loading a full recipe (and potentially input), so there is no - // need to set the staleness indicator. Just exit and wait until auto bake is called after loading - // has completed. - if (this.autoBakePause) return false; - if (this.baking) { this.manager.worker.cancelBakeForAutoBake(); this.baking = false; @@ -241,7 +235,7 @@ class App { action: "setInput", data: { inputNum: inputNum, - silent: false + silent: true } }); } @@ -478,7 +472,6 @@ class App { * @fires Manager#statechange */ loadURIParams(params=this.getURIParams()) { - this.autoBakePause = true; this.uriParams = params; // Read in recipe from URI params @@ -545,12 +538,7 @@ class App { this.manager.options.changeTheme(Utils.escapeHtml(this.uriParams.theme)); } - this.autoBakePause = false; - - // Dispatch stateChange only if not done by setInput - if (this.uriParams.input) { - window.dispatchEvent(this.manager.statechange); - } + window.dispatchEvent(this.manager.statechange); } @@ -583,10 +571,6 @@ class App { setRecipeConfig(recipeConfig) { document.getElementById("rec-list").innerHTML = null; - // Pause auto-bake while loading but don't modify `this.autoBake_` - // otherwise `manualBake` cannot trigger. - this.autoBakePause = true; - for (let i = 0; i < recipeConfig.length; i++) { const item = this.manager.recipe.addOperation(recipeConfig[i].op); @@ -621,9 +605,6 @@ class App { this.progress = 0; } - - // Unpause auto bake - this.autoBakePause = false; } diff --git a/src/web/waiters/InputWaiter.mjs b/src/web/waiters/InputWaiter.mjs index 637f827c..3999fd2f 100644 --- a/src/web/waiters/InputWaiter.mjs +++ b/src/web/waiters/InputWaiter.mjs @@ -215,7 +215,8 @@ class InputWaiter { * Handler for Chr Enc change events * Sets the input character encoding * @param {number} chrEncVal - * @param {boolean} [manual=false] + * @param {boolean} [manual=false] - Flag to indicate the encoding was set by the user + * @param {boolean} [internal=false] - Flag to indicate this was set internally, i.e. by loading from URI */ chrEncChange(chrEncVal, manual=false, internal=false) { if (typeof chrEncVal !== "number") return; @@ -641,10 +642,6 @@ class InputWaiter { const inputStr = toBase64(inputVal, "A-Za-z0-9+/"); this.app.updateURL(true, inputStr); } - - // Trigger a state change - if (!silent) window.dispatchEvent(this.manager.statechange); - }.bind(this)); }