]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/static/js/mail_folder_list.js
Grammar change in the license declaration.
[citadel.git] / webcit-ng / static / js / mail_folder_list.js
index 6647c03b263c77b274e99fa131ea8cf9740ce6cf..fff055d749385c43b58541680d291b40130d4232 100644 (file)
@@ -3,7 +3,7 @@
 // Copyright (c) 2016-2023 by the citadel.org team
 //
 // This program is open source software.  Use, duplication, or
-// disclosure are subject to the GNU General Public License v3.
+// disclosure is subject to the GNU General Public License v3.
 
 
 // Display the mail folder list in the specified div
@@ -93,6 +93,28 @@ function mail_folder_drop(event, destination_room) {
 
 
 // mail_folder_drop() calls this function for each message being moved
-function mail_move(msgdiv, destination_room) {
-       console.log("mail_move() " + msgdiv + " to " + destination_room);
+mail_move = async(msgdivid, destination_room) => {
+       let msgdiv = document.getElementById(msgdivid);
+       let m = parseInt(msgdivid.substring(12));                               // derive msgnum from row id
+       let source = "/ctdl/r/" + escapeHTMLURI(current_room) + "/" + m;
+       let destination = "/ctdl/r/" + escapeHTMLURI(destination_room);
+
+       let response = await fetch(
+               source, {
+                       method: "MOVE",
+                       headers: {
+                               "Destination" : destination
+                       }
+               }
+       );
+
+       // If the server accepted the MOVE operation, delete the row from our screen.
+       if (response.ok) {
+               var table = document.getElementById("ctdl-onscreen-mailbox");
+               for (var i = 0, row; row = table.rows[i]; i++) {
+                       if (row.id == msgdivid) {
+                               table.deleteRow(i);
+                       }
+               }
+       }
 }