Skip to content

Commit 188fd75

Browse files
committed
fix(frontend): cached messages do not update flag state when flag/unflag is performed via the list
1 parent 00593ec commit 188fd75

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

modules/core/site.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,14 @@ function Message_List() {
818818
$('.icon', row).empty();
819819
}
820820
flagged++;
821+
822+
// if the message content was present in the local storage, update it too
823+
const urlParams = new URLSearchParams(row.find('.subject a').attr('href'));
824+
const storageKey = getMessageStorageKey(row.data('uid'), urlParams.get('list_path'));
825+
const message = Hm_Utils.get_from_local_storage(storageKey);
826+
if (message) {
827+
set_message_content(urlParams.get('list_path'), row.data('uid'));
828+
}
821829
}
822830
return flagged;
823831
};

modules/imap/site.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ var set_message_content = function(path, msg_uid) {
109109
if (!path) {
110110
path = getListPathParam();
111111
}
112-
Hm_Utils.remove_from_local_storage(getMessageStorageKey(msg_uid));
112+
Hm_Utils.remove_from_local_storage(getMessageStorageKey(msg_uid, path));
113113
preFetchMessageContent(false, msg_uid, path);
114114
};
115115

@@ -528,7 +528,7 @@ var display_imap_mailbox = function(rows, id, store, checkEmptyState = true) {
528528
};
529529

530530
function preFetchMessageContent(msgPart, uid, path) {
531-
if (Hm_Utils.get_from_local_storage(getMessageStorageKey(uid))) {
531+
if (Hm_Utils.get_from_local_storage(getMessageStorageKey(uid, path))) {
532532
return;
533533
}
534534
const detail = Hm_Utils.parse_folder_path(path, 'imap');
@@ -540,12 +540,12 @@ function preFetchMessageContent(msgPart, uid, path) {
540540
{'name': 'folder', 'value': detail.folder},
541541
{'name': 'imap_prefetch', 'value': true}
542542
], (res) => {
543-
Hm_Utils.save_to_local_storage(getMessageStorageKey(uid), JSON.stringify(res));
543+
Hm_Utils.save_to_local_storage(getMessageStorageKey(uid, path), JSON.stringify(res));
544544
}, null, true)
545545
}
546546

547-
function getMessageStorageKey(uid) {
548-
return uid + '_' + getListPathParam();
547+
function getMessageStorageKey(uid, listPath = getListPathParam()) {
548+
return uid + '_' + listPath;
549549
}
550550

551551
async function markPrefetchedMessagesAsRead(uid) {

0 commit comments

Comments
 (0)