File loading progress is now updated

This commit is contained in:
n1474335 2022-11-04 18:29:53 +00:00
parent 44c7a1e92d
commit 61d4c0ea63
3 changed files with 31 additions and 32 deletions

View file

@ -779,9 +779,9 @@ class Utils {
"`": "`" "`": "`"
}; };
return str.replace(/[&<>"'`]/g, function (match) { return str ? str.replace(/[&<>"'`]/g, function (match) {
return HTML_CHARS[match]; return HTML_CHARS[match];
}); }) : str;
} }

View file

@ -18,11 +18,11 @@ class FileDetailsPanel {
* @param {Object} opts * @param {Object} opts
*/ */
constructor(opts) { constructor(opts) {
this.fileDetails = opts.fileDetails; this.fileDetails = opts?.fileDetails;
this.progress = opts.progress; this.progress = opts?.progress ?? 0;
this.status = opts.status; this.status = opts?.status;
this.buffer = opts.buffer; this.buffer = opts?.buffer;
this.renderPreview = opts.renderPreview; this.renderPreview = opts?.renderPreview;
this.dom = this.buildDOM(); this.dom = this.buildDOM();
this.renderFileThumb(); this.renderFileThumb();
} }
@ -42,20 +42,20 @@ class FileDetailsPanel {
<table class="file-details-data"> <table class="file-details-data">
<tr> <tr>
<td>Name:</td> <td>Name:</td>
<td class="file-details-name" title="${Utils.escapeHtml(this.fileDetails.name)}"> <td class="file-details-name" title="${Utils.escapeHtml(this.fileDetails?.name)}">
${Utils.escapeHtml(this.fileDetails.name)} ${Utils.escapeHtml(this.fileDetails?.name)}
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Size:</td> <td>Size:</td>
<td class="file-details-size" title="${Utils.escapeHtml(this.fileDetails.size)} bytes"> <td class="file-details-size" title="${Utils.escapeHtml(this.fileDetails?.size)} bytes">
${Utils.escapeHtml(this.fileDetails.size)} bytes ${Utils.escapeHtml(this.fileDetails?.size)} bytes
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Type:</td> <td>Type:</td>
<td class="file-details-type" title="${Utils.escapeHtml(this.fileDetails.type)}"> <td class="file-details-type" title="${Utils.escapeHtml(this.fileDetails?.type)}">
${Utils.escapeHtml(this.fileDetails.type)} ${Utils.escapeHtml(this.fileDetails?.type)}
</td> </td>
</tr> </tr>
<tr> <tr>

View file

@ -49,6 +49,7 @@ class InputWaiter {
this.maxTabs = this.manager.tabs.calcMaxTabs(); this.maxTabs = this.manager.tabs.calcMaxTabs();
this.callbacks = {}; this.callbacks = {};
this.callbackID = 0; this.callbackID = 0;
this.fileDetails = {};
this.maxWorkers = 1; this.maxWorkers = 1;
if (navigator.hardwareConcurrency !== undefined && if (navigator.hardwareConcurrency !== undefined &&
@ -542,15 +543,16 @@ class InputWaiter {
if (inputNum !== activeTab) return; if (inputNum !== activeTab) return;
// Create file details panel // Create file details panel
this.fileDetails = {
fileDetails: inputData.file,
progress: inputData.progress,
status: inputData.status,
buffer: inputData.buffer,
renderPreview: this.app.options.imagePreview
};
this.inputEditorView.dispatch({ this.inputEditorView.dispatch({
effects: this.inputEditorConf.fileDetailsPanel.reconfigure( effects: this.inputEditorConf.fileDetailsPanel.reconfigure(
fileDetailsPanel({ fileDetailsPanel(this.fileDetails)
fileDetails: inputData.file,
progress: inputData.progress,
status: inputData.status,
buffer: inputData.buffer,
renderPreview: this.app.options.imagePreview
})
) )
}); });
} }
@ -599,19 +601,16 @@ class InputWaiter {
* @param {number | string} progress - Either a number or "error" * @param {number | string} progress - Either a number or "error"
*/ */
updateFileProgress(inputNum, progress) { updateFileProgress(inputNum, progress) {
// const activeTab = this.manager.tabs.getActiveTab("input"); const activeTab = this.manager.tabs.getActiveTab("input");
// if (inputNum !== activeTab) return; if (inputNum !== activeTab) return;
// TODO this.fileDetails.progress = progress;
if (progress === "error") this.fileDetails.status = "error";
// const fileLoaded = document.getElementById("input-file-loaded"); this.inputEditorView.dispatch({
// if (progress === "error") { effects: this.inputEditorConf.fileDetailsPanel.reconfigure(
// fileLoaded.textContent = "Error"; fileDetailsPanel(this.fileDetails)
// fileLoaded.style.color = "#FF0000"; )
// } else { });
// fileLoaded.textContent = progress + "%";
// fileLoaded.style.color = "";
// }
} }
/** /**