From fc40580dce944a36b2a15e8afa0278407bc58f27 Mon Sep 17 00:00:00 2001 From: zb3 Date: Fri, 5 Apr 2024 18:48:45 +0200 Subject: [PATCH 1/2] Avoid calling inputChange when setting encoding inside loadURIParams Otherwise the debounce logic sometimes causes the input to be overriden by the previous value. --- src/web/App.mjs | 2 +- src/web/waiters/InputWaiter.mjs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/web/App.mjs b/src/web/App.mjs index 53070e26..8dcb959a 100755 --- a/src/web/App.mjs +++ b/src/web/App.mjs @@ -502,7 +502,7 @@ class App { // Input Character Encoding // Must be set before the input is loaded if (this.uriParams.ienc) { - this.manager.input.chrEncChange(parseInt(this.uriParams.ienc, 10), true); + this.manager.input.chrEncChange(parseInt(this.uriParams.ienc, 10), true, true); } // Output Character Encoding diff --git a/src/web/waiters/InputWaiter.mjs b/src/web/waiters/InputWaiter.mjs index bffca98c..637f827c 100644 --- a/src/web/waiters/InputWaiter.mjs +++ b/src/web/waiters/InputWaiter.mjs @@ -217,11 +217,13 @@ class InputWaiter { * @param {number} chrEncVal * @param {boolean} [manual=false] */ - chrEncChange(chrEncVal, manual=false) { + chrEncChange(chrEncVal, manual=false, internal=false) { if (typeof chrEncVal !== "number") return; this.inputChrEnc = chrEncVal; this.encodingState = manual ? 2 : this.encodingState; - this.inputChange(); + if (!internal) { + this.inputChange(); + } } /** From 1adc2ff9305a95dd0b5c8c15288857c1cf1d58ce Mon Sep 17 00:00:00 2001 From: zb3 Date: Fri, 5 Apr 2024 18:52:50 +0200 Subject: [PATCH 2/2] Make loadURIParams set input non-silently Silent input changes might be overwritten due to the debounce logic present inside inputChange. --- src/web/App.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/web/App.mjs b/src/web/App.mjs index 8dcb959a..e5989fe4 100755 --- a/src/web/App.mjs +++ b/src/web/App.mjs @@ -236,7 +236,7 @@ class App { action: "setInput", data: { inputNum: inputNum, - silent: true + silent: false } }); } @@ -541,7 +541,11 @@ class App { } this.autoBakePause = false; - window.dispatchEvent(this.manager.statechange); + + // Dispatch stateChange only if not done by setInput + if (this.uriParams.input) { + window.dispatchEvent(this.manager.statechange); + } }