upload.js: when removing an attachment, delete the div
authorArt Cancro <ajc@citadel.org>
Tue, 21 Nov 2023 00:00:13 +0000 (19:00 -0500)
committerArt Cancro <ajc@citadel.org>
Tue, 21 Nov 2023 00:00:13 +0000 (19:00 -0500)
This is handled the usual way, when we get a successful response from
the HTTP DELETE method, it triggers the removal of the list element
showing the attachment.

webcit-ng/static/js/upload.js
webcit-ng/static/js/view_mail.js

index 5541213724bc4044b88cd177202a4c6e652eb21b..5ae027c8f6f506fef9903e75fb5377676fc96483 100644 (file)
@@ -82,7 +82,9 @@ delete_upload = async(ref) => {
        );
 
        if (response.ok) {                              // If the server accepted the delete, remove it from the screen
-               // FIXME do the delete
+               console.log("server deleted " + ref);
+               var el = document.getElementById(ref);
+               el.parentNode.removeChild(el);
        }
 }
 
@@ -106,7 +108,7 @@ function upload_file(file) {
                        // Add these uploads to the displayed list
                        j_response.forEach((item) => {
                                let new_upl = document.createElement("li");
-                               // item["ref"] is what we need
+                               new_upl.setAttribute("id", item["ref"]);        // set the element id to the upload reference
                                new_upl.innerHTML = `<i class="fa-solid fa-circle-xmark" style="color:red" onClick="delete_upload('` + item["ref"] + `')"></i>`
                                + `&nbsp;`
                                + item["uploadfilename"] + " (" + item["contenttype"] + ", " + item["contentlength"] + " " + _("bytes") + ")";
index 0efdf37f6ad60b2b77aae3810fbfb2249f0948ae..d058f470ecf35727d3820f4e455275e6c4c720d2 100644 (file)
@@ -372,9 +372,9 @@ function refresh_mail_display() {
        fetch_stat = async() => {
                response = await fetch(url);
                stat = await(response.json());
-               if (stat.room_mtime > room_mtime) {                     // FIXME commented out to force refreshes
+               if (stat.room_mtime > room_mtime) {                     // if modified...
                        room_mtime = stat.room_mtime;
-                       render_mailbox_display(newmail_notify.YES);
+                       render_mailbox_display(newmail_notify.YES);     // ...force a refresh
                }
        }
        fetch_stat();