Commit 12f9fdb8 authored by Nicolas Pernoud's avatar Nicolas Pernoud
Browse files

fix: preview on uploading or deleting images

parent 4989b89a
Pipeline #14627 passed with stages
in 2 minutes and 44 seconds
......@@ -433,7 +433,7 @@ export class Explorer {
throw new Error(`File could not be deleted (status ${response.status})`);
}
this.files = this.files.filter((el) => el.name !== file.name);
this.displayFiles();
document.getElementById(`file-${file.id}-content`).outerHTML = "";
} catch (e) {
HandleError(e);
}
......@@ -442,7 +442,7 @@ export class Explorer {
async upload(files) {
const onStartPath = this.path;
let id = this.files.length;
let id = Math.max(...this.files.map((o) => o.id), 0);
let fileIdx = 0;
for (const file of files) {
// Check for overwrite
......@@ -450,7 +450,6 @@ export class Explorer {
Messages.Show("is-warning", `A file with the name "${file.name}" already exists, please remove the old file before upload.`);
continue;
}
id++;
fileIdx++;
file.path = path(onStartPath, file.name);
// Create a message to allow progress tracking and cancellation
......@@ -489,16 +488,12 @@ export class Explorer {
try {
await this.uploadFile(xhr, file);
if (this.path === onStartPath) {
this.files.push({
name: file.name,
path: file.path,
isDir: file.isDir,
type: file.type,
size: file.size,
lastModified: file.lastModified,
id: id,
});
this.displayFiles();
id++;
const newFile = { name: file.name, path: file.path, isDir: file.isDir, type: file.type, size: file.size, lastModified: file.lastModified, id: id };
this.files.push(newFile);
const markup = this.fileTemplate(newFile);
document.getElementById(`file-${id - 1}-content`).insertAdjacentHTML("afterend", markup);
this.registerEvents(newFile);
}
} catch (e) {
console.error(e.statusText);
......
......@@ -32,7 +32,7 @@
<div class="navbar-brand">
<div class="navbar-item">
<a class="button is-primary is-rounded is-outlined" href="https://www.github.com/nicolaspernoud/Vestibule" target="_blank" rel="noopener noreferrer">
<span>4.5.14</span>
<span>4.5.15</span>
<span class="icon">
<svg
class="svg-inline--fa fa-github fa-w-16"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment