From d6abb9afc9d1e72f7424d1e19c44e47e2a1d0268 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 26 Dec 2022 18:57:11 -0500 Subject: [PATCH] Multi select is now working with mailbox refresh. This completes the changes needed to maintain multi select. We are NOT keeping a separate array for selected and unselected messages. Instead, we are using the DOM itself as authority. --- webcit-ng/static/js/view_mail.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/webcit-ng/static/js/view_mail.js b/webcit-ng/static/js/view_mail.js index 93baf75d3..50e56eac4 100644 --- a/webcit-ng/static/js/view_mail.js +++ b/webcit-ng/static/js/view_mail.js @@ -189,9 +189,10 @@ function click_message(event, msgnum) { // render one row in the mailbox table (this could be called from one of several places) -function mail_render_row(msg) { +function mail_render_row(msg, is_selected) { row = "" @@ -245,10 +246,10 @@ 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) { // FIXME commented out to force refreshes room_mtime = stat.room_mtime; render_mailbox_display(newmail_notify.YES); - //} + } } fetch_stat(); } @@ -263,7 +264,20 @@ function render_mailbox_display(notify) { response = await fetch(url); msgs = await(response.json()); if (response.ok) { + var previously_selected = []; + var oldtable = document.getElementById("ctdl-onscreen-mailbox"); + var i, row; + + // If one or more messages was already selected, remember them so we can re-select them + if (displayed_message > 0) { + for (i=0; row=oldtable.rows[i]; ++i) { + if (row.classList.contains("ctdl-mail-selected")) { + previously_selected.push(parseInt(row["id"].substring(12))); + } + } + } + // begin rendering the mailbox table box = "" + "" + "" @@ -272,8 +286,9 @@ function render_mailbox_display(notify) { + ""; for (let i=0; i highest_mailnum) { highest_mailnum = m; } @@ -281,11 +296,6 @@ function render_mailbox_display(notify) { box += "
" + _("Subject") + "" + _("Sender") + "
"; document.getElementById("ctdl-mailbox-pane").innerHTML = box; - - // FIXME redo this for multi select - //if (displayed_message > 0) { // if we had a message selected, keep it selected - //select_message(null, displayed_message); - //} } } fetch_mailbox(); -- 2.39.2