Skip to content

Commit

Permalink
Removed autoBakePause flag and statechange trigger in InputWaiter.set…
Browse files Browse the repository at this point in the history
…() as they are redundant.
  • Loading branch information
n1474335 committed Apr 24, 2024
1 parent 0a709ac commit a79be1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
23 changes: 2 additions & 21 deletions src/web/App.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class App {

this.baking = false;
this.autoBake_ = false;
this.autoBakePause = false;
this.progress = 0;
this.ingId = 0;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -241,7 +235,7 @@ class App {
action: "setInput",
data: {
inputNum: inputNum,
silent: false
silent: true
}
});
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -621,9 +605,6 @@ class App {

this.progress = 0;
}

// Unpause auto bake
this.autoBakePause = false;
}


Expand Down
7 changes: 2 additions & 5 deletions src/web/waiters/InputWaiter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

Expand Down

0 comments on commit a79be1e

Please sign in to comment.