Fix some weirdness with tabs.
Adjust worker logic to avoid closing and reopening a worker as often
This commit is contained in:
parent
9df26b8c84
commit
1eadc08098
@ -170,7 +170,6 @@ class InputWaiter {
|
|||||||
*/
|
*/
|
||||||
closeFile(inputNum) {
|
closeFile(inputNum) {
|
||||||
this.removeLoaderWorker(this.getLoaderWorker(inputNum));
|
this.removeLoaderWorker(this.getLoaderWorker(inputNum));
|
||||||
this.removeInput(inputNum);
|
|
||||||
|
|
||||||
if (inputNum === this.getActiveTab()) {
|
if (inputNum === this.getActiveTab()) {
|
||||||
const fileOverlay = document.getElementById("input-file"),
|
const fileOverlay = document.getElementById("input-file"),
|
||||||
@ -670,7 +669,9 @@ class InputWaiter {
|
|||||||
*/
|
*/
|
||||||
displayTabInfo(inputNum) {
|
displayTabInfo(inputNum) {
|
||||||
const tabItem = this.getTabItem(inputNum);
|
const tabItem = this.getTabItem(inputNum);
|
||||||
const input = this.inputs[this.getInputIndex(inputNum)];
|
const index = this.getInputIndex(inputNum);
|
||||||
|
if (index === -1) return;
|
||||||
|
const input = this.inputs[index];
|
||||||
if (!tabItem) {
|
if (!tabItem) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -756,7 +757,6 @@ class InputWaiter {
|
|||||||
} else {
|
} else {
|
||||||
inputNum = this.getLargestInputNum() + 1;
|
inputNum = this.getLargestInputNum() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.inputs.push({
|
this.inputs.push({
|
||||||
inputNum: inputNum,
|
inputNum: inputNum,
|
||||||
data: "",
|
data: "",
|
||||||
@ -764,6 +764,7 @@ class InputWaiter {
|
|||||||
progress: 100
|
progress: 100
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this.manager.output.addOutput(inputNum, changeTab);
|
this.manager.output.addOutput(inputNum, changeTab);
|
||||||
|
|
||||||
const tabsWrapper = document.getElementById("input-tabs");
|
const tabsWrapper = document.getElementById("input-tabs");
|
||||||
@ -917,6 +918,7 @@ class InputWaiter {
|
|||||||
inputs.sort(function(a, b) {
|
inputs.sort(function(a, b) {
|
||||||
return b - a;
|
return b - a;
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (reachedEnd) {
|
if (reachedEnd) {
|
||||||
newNum = this.getPreviousInputNum(inputs[i-1]);
|
newNum = this.getPreviousInputNum(inputs[i-1]);
|
||||||
@ -940,6 +942,7 @@ class InputWaiter {
|
|||||||
inputs.sort(function(a, b) {
|
inputs.sort(function(a, b) {
|
||||||
return b - a;
|
return b - a;
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (reachedEnd) {
|
if (reachedEnd) {
|
||||||
newNum = this.getNextInputNum(inputs[i-1]);
|
newNum = this.getNextInputNum(inputs[i-1]);
|
||||||
@ -998,7 +1001,7 @@ class InputWaiter {
|
|||||||
|
|
||||||
const input = this.getInput(inputNum);
|
const input = this.getInput(inputNum);
|
||||||
if (typeof input === "string") {
|
if (typeof input === "string") {
|
||||||
this.set(this.getInput(inputNum));
|
this.set(this.getInput(inputNum), true);
|
||||||
} else {
|
} else {
|
||||||
this.setFile(inputNum);
|
this.setFile(inputNum);
|
||||||
}
|
}
|
||||||
@ -1157,6 +1160,7 @@ class InputWaiter {
|
|||||||
* Resets the input, output and info areas
|
* Resets the input, output and info areas
|
||||||
*/
|
*/
|
||||||
clearAllIoClick() {
|
clearAllIoClick() {
|
||||||
|
this.manager.worker.cancelBake();
|
||||||
for (let i = this.inputs.length - 1; i >= 0; i--) {
|
for (let i = this.inputs.length - 1; i >= 0; i--) {
|
||||||
this.removeTab(this.inputs[i].inputNum);
|
this.removeTab(this.inputs[i].inputNum);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ class Manager {
|
|||||||
* Sets up the various components and listeners.
|
* Sets up the various components and listeners.
|
||||||
*/
|
*/
|
||||||
setup() {
|
setup() {
|
||||||
this.input.addTab();
|
this.input.addTab(true);
|
||||||
this.input.setupLoaderWorker();
|
this.input.setupLoaderWorker();
|
||||||
this.worker.setupChefWorker();
|
this.worker.setupChefWorker();
|
||||||
this.recipe.initialiseOperationDragNDrop();
|
this.recipe.initialiseOperationDragNDrop();
|
||||||
|
@ -408,13 +408,11 @@ class OutputWaiter {
|
|||||||
const zip = new Zlib.Zip();
|
const zip = new Zlib.Zip();
|
||||||
for (let i = 0; i < this.outputs.length; i++) {
|
for (let i = 0; i < this.outputs.length; i++) {
|
||||||
const name = Utils.strToByteArray(this.outputs[i].inputNum + fileExt);
|
const name = Utils.strToByteArray(this.outputs[i].inputNum + fileExt);
|
||||||
log.error(this.getOutput(this.outputs[i].inputNum));
|
|
||||||
let out = this.getOutput(this.outputs[i].inputNum);
|
let out = this.getOutput(this.outputs[i].inputNum);
|
||||||
if (typeof out === "string") {
|
if (typeof out === "string") {
|
||||||
out = Utils.strToUtf8ByteArray(out);
|
out = Utils.strToUtf8ByteArray(out);
|
||||||
}
|
}
|
||||||
out = new Uint8Array(out);
|
out = new Uint8Array(out);
|
||||||
log.error(out);
|
|
||||||
// options.filename = Utils.strToByteArray(this.outputs[i].inputNum + ".dat");
|
// options.filename = Utils.strToByteArray(this.outputs[i].inputNum + ".dat");
|
||||||
zip.addFile(out, {filename: name});
|
zip.addFile(out, {filename: name});
|
||||||
}
|
}
|
||||||
@ -569,6 +567,7 @@ class OutputWaiter {
|
|||||||
nums.sort(function(a, b) {
|
nums.sort(function(a, b) {
|
||||||
return b - a;
|
return b - a;
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (reachedEnd) {
|
if (reachedEnd) {
|
||||||
newNum = this.getPreviousInputNum(nums[i-1]);
|
newNum = this.getPreviousInputNum(nums[i-1]);
|
||||||
@ -592,6 +591,7 @@ class OutputWaiter {
|
|||||||
nums.sort(function(a, b) {
|
nums.sort(function(a, b) {
|
||||||
return b - a;
|
return b - a;
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (reachedEnd) {
|
if (reachedEnd) {
|
||||||
newNum = this.getNextInputNum(nums[i-1]);
|
newNum = this.getNextInputNum(nums[i-1]);
|
||||||
|
@ -93,8 +93,10 @@ class WorkerWaiter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.chefWorkers[index].worker.terminate();
|
if (this.chefWorkers.length > 1 || this.chefWorkers[index].active) {
|
||||||
this.chefWorkers.splice(index, 1);
|
this.chefWorkers[index].worker.terminate();
|
||||||
|
this.chefWorkers.splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// There should always be a ChefWorker loaded
|
// There should always be a ChefWorker loaded
|
||||||
if (this.chefWorkers.length === 0) {
|
if (this.chefWorkers.length === 0) {
|
||||||
@ -158,6 +160,7 @@ class WorkerWaiter {
|
|||||||
} else {
|
} else {
|
||||||
// The ChefWorker is no longer needed
|
// The ChefWorker is no longer needed
|
||||||
log.debug("No more inputs to bake. Closing ChefWorker.");
|
log.debug("No more inputs to bake. Closing ChefWorker.");
|
||||||
|
currentWorker.active = false;
|
||||||
this.removeChefWorker(currentWorker);
|
this.removeChefWorker(currentWorker);
|
||||||
|
|
||||||
this.displayProgress();
|
this.displayProgress();
|
||||||
@ -216,7 +219,7 @@ class WorkerWaiter {
|
|||||||
this.manager.output.updateOutputValue(data, inputNum);
|
this.manager.output.updateOutputValue(data, inputNum);
|
||||||
this.manager.output.updateOutputStatus("baked", inputNum);
|
this.manager.output.updateOutputStatus("baked", inputNum);
|
||||||
|
|
||||||
this.manager.recipe.updateBreakpointIndicator(this.app.progress);
|
// this.manager.recipe.updateBreakpointIndicator(this.app.progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -280,11 +283,12 @@ class WorkerWaiter {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// What are these for?
|
|
||||||
// Should be a value for each input, not just one
|
// Should be a value for each input, not just one
|
||||||
|
// Get store the progress for every output
|
||||||
|
// When we run set(), update the breakpoint indicator then
|
||||||
// this.app.progress = this.outputs[0].data.progress;
|
// this.app.progress = this.outputs[0].data.progress;
|
||||||
// this.app.dish = this.outputs[0].data.dish;
|
// this.app.dish = this.outputs[0].data.dish;
|
||||||
this.manager.recipe.updateBreakpointIndicator(this.app.progress);
|
// this.manager.recipe.updateBreakpointIndicator(this.app.progress);
|
||||||
// Don't need to update the output here as updateOutput() will take care of that
|
// Don't need to update the output here as updateOutput() will take care of that
|
||||||
document.getElementById("bake").style.background = "";
|
document.getElementById("bake").style.background = "";
|
||||||
this.totalOutputs = 0; // Reset for next time
|
this.totalOutputs = 0; // Reset for next time
|
||||||
|
Loading…
Reference in New Issue
Block a user