// 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);
+ }
+ }
+ }
}