From c0342d49133f1fff5057077e513cdf02f3123746 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 19 Nov 2023 13:39:12 -0500 Subject: [PATCH] When a mail compose is canceled, flush all uploads. Most of this was already in place. We now just run through our upload list and do an async DELETE operation for each one. --- webcit-ng/static/js/upload.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/webcit-ng/static/js/upload.js b/webcit-ng/static/js/upload.js index ac72bbee8..554121372 100644 --- a/webcit-ng/static/js/upload.js +++ b/webcit-ng/static/js/upload.js @@ -165,6 +165,15 @@ function show_or_hide_upload_window() { } +// Helper function for flush_uploads() +flush_one_upload = async(ref) => { + response = await fetch( + "/ctdl/p/" + ref, { method: "DELETE" } + ); + // We don't have any interest in the server response. +} + + // Flush all uploaded files and close the window function flush_uploads() { upload_window = document.getElementById('ctdl-upload'); @@ -173,9 +182,9 @@ function flush_uploads() { upload_window.style.display='none'; } - // FIXME tell the server to delete the files + // tell the server to delete the files uploads.forEach(u => { - console.log(u.ref); + flush_one_upload(u.ref); }); uploads=[]; -- 2.30.2