diff --git a/src/core/ChefWorker.js b/src/core/ChefWorker.js index de6e7eac..e1deaf0d 100644 --- a/src/core/ChefWorker.js +++ b/src/core/ChefWorker.js @@ -102,37 +102,15 @@ async function bake(data) { data.progress, // The current position in the recipe data.step // Whether or not to take one step or execute the whole recipe ); - if (typeof response.result === "string") { - if (response.progress !== data.progress + data.recipeConfig.length) { - self.postMessage({ - action: "bakeError", - data: { - error: response.result, - id: data.id, - inputNum: data.inputNum, - progress: response.progress - } - }); - } else { - self.postMessage({ - action: "bakeComplete", - data: Object.assign(response, { - id: data.id, - inputNum: data.inputNum, - bakeId: data.bakeId - }) - }); - } - } else { - self.postMessage({ - action: "bakeComplete", - data: Object.assign(response, { - id: data.id, - inputNum: data.inputNum, - bakeId: data.bakeId - }) - }, [response.result]); - } + self.postMessage({ + action: "bakeComplete", + data: Object.assign(response, { + id: data.id, + inputNum: data.inputNum, + bakeId: data.bakeId, + progress: response.progress + }) + }); } catch (err) { self.postMessage({ action: "bakeError", diff --git a/src/web/ControlsWaiter.mjs b/src/web/ControlsWaiter.mjs index f2997ff0..197b85ab 100755 --- a/src/web/ControlsWaiter.mjs +++ b/src/web/ControlsWaiter.mjs @@ -5,7 +5,6 @@ */ import Utils from "../core/Utils"; -import {toBase64} from "../core/lib/Base64"; /** diff --git a/src/web/InputWorker.mjs b/src/web/InputWorker.mjs index 817c704a..e1481c08 100644 --- a/src/web/InputWorker.mjs +++ b/src/web/InputWorker.mjs @@ -7,7 +7,6 @@ */ import Utils from "../core/Utils"; -import {toBase64} from "../core/lib/Base64"; self.maxWorkers = 4; self.maxTabs = 1; diff --git a/src/web/OutputWaiter.mjs b/src/web/OutputWaiter.mjs index cc05dd85..5aa45cab 100755 --- a/src/web/OutputWaiter.mjs +++ b/src/web/OutputWaiter.mjs @@ -172,7 +172,6 @@ class OutputWaiter { if (status !== "error") { delete this.outputs[inputNum].error; - delete this.outputs[inputNum].progress; } this.set(inputNum); @@ -189,6 +188,17 @@ class OutputWaiter { this.outputs[inputNum].bakeId = bakeId; } + /** + * Updates the stored progress value for the output in the output array + * + * @param {number} progress + * @param {number} inputNum + */ + updateOutputProgress(progress, inputNum) { + if (this.getOutput(inputNum) === -1) return; + this.outputs[inputNum].progress = progress; + } + /** * Removes an output from the output array. * @@ -240,7 +250,11 @@ class OutputWaiter { this.manager.controls.hideStaleIndicator(); } - this.manager.recipe.updateBreakpointIndicator(false); + if (output.progress !== undefined) { + this.manager.recipe.updateBreakpointIndicator(output.progress); + } else { + this.manager.recipe.updateBreakpointIndicator(false); + } document.getElementById("show-file-overlay").style.display = "none"; @@ -263,8 +277,6 @@ class OutputWaiter { outputText.value = output.error; outputHtml.innerHTML = ""; - - this.manager.recipe.updateBreakpointIndicator(output.progress); } else if (output.status === "baked" || output.status === "inactive") { this.displayTabInfo(inputNum); this.toggleLoader(false); @@ -1122,7 +1134,6 @@ class OutputWaiter { } - /** * Handler for copy click events. * Copies the output to the clipboard diff --git a/src/web/WorkerWaiter.mjs b/src/web/WorkerWaiter.mjs index b9385878..02220368 100644 --- a/src/web/WorkerWaiter.mjs +++ b/src/web/WorkerWaiter.mjs @@ -142,11 +142,18 @@ class WorkerWaiter { switch (r.action) { case "bakeComplete": log.debug(`Bake ${inputNum} complete.`); - this.updateOutput(r.data, r.data.inputNum, r.data.bakeId); - this.workerFinished(currentWorker); + + if (r.data.error) { + this.app.handleError(r.data.error); + this.manager.output.updateOutputError(r.data.result, inputNum, r.data.progress); + this.workerFinished(currentWorker); + } else { + this.updateOutput(r.data, r.data.inputNum, r.data.bakeId, r.data.progress); + this.workerFinished(currentWorker); + } break; case "bakeError": - if (!r.data.hasOwnProperty("progress")) this.app.handleError(r.data.error); + this.app.handleError(r.data.error); this.manager.output.updateOutputError(r.data.error, inputNum, r.data.progress); this.app.progress = r.data.progress; this.workerFinished(currentWorker); @@ -190,9 +197,11 @@ class WorkerWaiter { * @param {Object} data * @param {number} inputNum * @param {number} bakeId + * @param {number} progress */ - updateOutput(data, inputNum, bakeId) { + updateOutput(data, inputNum, bakeId, progress) { this.manager.output.updateOutputBakeId(bakeId, inputNum); + this.manager.output.updateOutputProgress(progress, inputNum); this.manager.output.updateOutputValue(data, inputNum); this.manager.output.updateOutputStatus("baked", inputNum); // this.manager.recipe.updateBreakpointIndicator(this.app.progress);