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];
});
}) : str;
}

View File

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

View File

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