Manual bake now triggers when recipes are loaded from the URL. Fixes #93.

This commit is contained in:
n1474335 2017-06-09 15:36:15 +00:00
parent 69e12b1067
commit e7f5b17184
2 changed files with 20 additions and 20 deletions

View file

@ -21,21 +21,22 @@ import Split from "split.js";
* @param {Object} options - Default setting for app options. * @param {Object} options - Default setting for app options.
*/ */
const App = function(categories, operations, defaultFavourites, defaultOptions) { const App = function(categories, operations, defaultFavourites, defaultOptions) {
this.categories = categories; this.categories = categories;
this.operations = operations; this.operations = operations;
this.dfavourites = defaultFavourites; this.dfavourites = defaultFavourites;
this.doptions = defaultOptions; this.doptions = defaultOptions;
this.options = Utils.extend({}, defaultOptions); this.options = Utils.extend({}, defaultOptions);
this.chef = new Chef(); this.chef = new Chef();
this.manager = new Manager(this); this.manager = new Manager(this);
this.baking = false; this.baking = false;
this.autoBake_ = false; this.autoBake_ = false;
this.progress = 0; this.autoBakePause = false;
this.ingId = 0; this.progress = 0;
this.ingId = 0;
window.chef = this.chef; window.chef = this.chef;
}; };
@ -166,7 +167,7 @@ App.prototype.bake = async function(step) {
* Runs Auto Bake if it is set. * Runs Auto Bake if it is set.
*/ */
App.prototype.autoBake = function() { App.prototype.autoBake = function() {
if (this.autoBake_) { if (this.autoBake_ && !this.autoBakePause) {
this.bake(); this.bake();
} }
}; };
@ -413,9 +414,9 @@ App.prototype.loadURIParams = function() {
return b; return b;
})(window.location.search.substr(1).split("&")); })(window.location.search.substr(1).split("&"));
// Turn off auto-bake while loading // Pause auto-bake while loading but don't modify `this.autoBake_`
const autoBakeVal = this.autoBake_; // otherwise `manualBake` cannot trigger.
this.autoBake_ = false; this.autoBakePause = true;
// Read in recipe from query string // Read in recipe from query string
if (this.queryString.recipe) { if (this.queryString.recipe) {
@ -451,8 +452,8 @@ App.prototype.loadURIParams = function() {
} catch (err) {} } catch (err) {}
} }
// Restore auto-bake state // Unpause auto-bake
this.autoBake_ = autoBakeVal; this.autoBakePause = false;
this.autoBake(); this.autoBake();
}; };

View file

@ -354,8 +354,7 @@ RecipeWaiter.prototype.buildRecipeOperation = function(el) {
el.classList.add("flow-control-op"); el.classList.add("flow-control-op");
} }
// Disable auto-bake if this is a manual op - this should be moved to the 'operationadd' // Disable auto-bake if this is a manual op
// handler after event restructuring
if (op.manualBake && this.app.autoBake_) { if (op.manualBake && this.app.autoBake_) {
this.manager.controls.setAutoBake(false); this.manager.controls.setAutoBake(false);
this.app.alert("Auto-Bake is disabled by default when using this operation.", "info", 5000); this.app.alert("Auto-Bake is disabled by default when using this operation.", "info", 5000);