From 66533461be273f90193c7869a93f87e8e7ed23d8 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 7 Dec 2023 18:51:32 -0500 Subject: [PATCH] view_mail.js: remove upload from local array when deleted. This makes the Attachments: counter decrement correctly. --- webcit-ng/static/js/upload.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webcit-ng/static/js/upload.js b/webcit-ng/static/js/upload.js index cc4c5fc2b..257ff7562 100644 --- a/webcit-ng/static/js/upload.js +++ b/webcit-ng/static/js/upload.js @@ -81,9 +81,11 @@ delete_upload = async(ref) => { "/ctdl/p/" + ref, { method: "DELETE" } ); - if (response.ok) { // If the server accepted the delete, remove it from the screen - var el = document.getElementById(ref); + if (response.ok) { // If the server accepted the delete... + var el = document.getElementById(ref); // ...remove it from the screen... el.parentNode.removeChild(el); + uploads = uploads.filter((r) => r.ref != ref); // ...remove it from the array... + document.getElementById("num_attachments").innerHTML = uploads.length; // ...and update our count } } @@ -188,6 +190,7 @@ function flush_uploads() { flush_one_upload(u.ref); }); uploads=[]; + document.getElementById("num_attachments").innerHTML = uploads.length; deactivate_uploads(); // this makes the window get destroyed too } -- 2.30.2