Skip to content

Commit

Permalink
fix(frontend): when opening an unread message, the counter does not g…
Browse files Browse the repository at this point in the history
…et updated
  • Loading branch information
mercihabam committed Feb 13, 2025
1 parent cd509bb commit 5a03d28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 0 additions & 2 deletions modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ var Hm_Ajax_Request = function() { return {
if (res.folder_status) {
for (const name in res.folder_status) {
if (name === getListPathParam()) {
Hm_Folders.unread_counts[name] = res.folder_status[name]['unseen'];
Hm_Folders.update_unread_counts();
const messages = new Hm_MessagesStore(name, Hm_Utils.get_url_page_number(), `${getParam('keyword')}_${getParam('filter')}`);
messages.load().then(() => {
if (messages.count != res.folder_status[name].messages) {
Expand Down
13 changes: 5 additions & 8 deletions modules/imap/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ function getMessageStorageKey(uid) {
async function markPrefetchedMessagesAsRead(uid) {
const listPath = getListPathParam();
const detail = Hm_Utils.parse_folder_path(listPath, 'imap');
const msgId = `${detail.type}_${detail.server_id}_${uid}_${detail.folder}`;
const msgId = `${detail.type}_${detail.server_id}_${uid}_${detail.folder}`;

const messages = new Hm_MessagesStore(listPath, Hm_Utils.get_url_page_number(), `${getParam('keyword')}_${getParam('filter')}`);
await messages.load(false, true);
Expand Down Expand Up @@ -761,6 +761,9 @@ var imap_message_view_finished = function(msg_uid, detail, listParent, skip_link
Hm_Message_List.adjust_unread_total(-1);
}
}

markPrefetchedMessagesAsRead(msg_uid);

$('.all_headers').on("click", function() { return Hm_Utils.toggle_long_headers(); });
$('.small_headers').on("click", function() { return Hm_Utils.toggle_long_headers(); });
$('#flag_msg').on("click", function() { return imap_flag_message($(this).data('state')); });
Expand Down Expand Up @@ -825,16 +828,10 @@ var imap_setup_message_view_page = function(uid, details, list_path, listParent,
if (!uid) {
uid = getMessageUidParam();
}
const callbackFn = (...args) => {
markPrefetchedMessagesAsRead(uid);
if (callback) {
callback(...args);
}
};

const msg_content = get_local_message_content(uid, list_path);
if (!msg_content) {
get_message_content(false, uid, list_path, listParent, details, callbackFn);
get_message_content(false, uid, list_path, listParent, details, callback);
}
else {
const msgResponse = JSON.parse(msg_content);
Expand Down

0 comments on commit 5a03d28

Please sign in to comment.