Skip to content

Commit

Permalink
fix(frontend): Remove deleted message from store
Browse files Browse the repository at this point in the history
  • Loading branch information
josaphatim committed Feb 17, 2025
1 parent 18965ef commit 4ae608f
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions modules/imap/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,15 @@ var imap_delete_message = function(state, supplied_uid, supplied_detail) {
{'name': 'imap_msg_uid', 'value': uid},
{'name': 'imap_server_id', 'value': detail.server_id},
{'name': 'folder', 'value': detail.folder}],
function(res) {
async function(res) {
if (!res.imap_delete_error) {
if (Hm_Utils.get_from_global('msg_uid', false)) {
return;
}
var msg_cache_key = 'imap_'+detail.server_id+'_'+getMessageUidParam()+'_'+detail.folder;
remove_from_cached_imap_pages(msg_cache_key);
const store = new Hm_MessagesStore(getListPathParam(), Hm_Utils.get_url_page_number());
await store.load(false, true);
store.removeRow(getMessageUidParam());

var nlink = $('.nlink');
if (nlink.length && Hm_Utils.get_from_global('auto_advance_email_enabled')) {
Hm_Utils.redirect(nlink.attr('href'));
Expand Down Expand Up @@ -363,24 +365,6 @@ var fetch_cached_imap_page = function() {
return [ page, links ];
}

var remove_from_cached_imap_pages = function(msg_cache_key) {
var keys = ['imap_'+Hm_Utils.get_url_page_number()+'_'+getListPathParam()];
if (hm_list_parent()) {
keys.push('imap_'+Hm_Utils.get_url_page_number()+'_'+hm_list_parent());
if (['combined_inbox', 'unread', 'flagged', 'advanced_search', 'search', 'sent'].includes(hm_list_parent())) {
keys.push('formatted_'+hm_list_parent());
}
}
keys.forEach(function(key) {
var data = Hm_Utils.get_from_local_storage(key);
if (data) {
var page_data = $('<div></div>').append(data);
page_data.find('.'+msg_cache_key).remove();
Hm_Utils.save_to_local_storage(key, page_data.html());
}
});
}

async function select_imap_folder(path, page = 1,reload, processInTheBackground = false, abortController = null) {
const messages = new Hm_MessagesStore(path, page, null, abortController);
await messages.load(reload, processInTheBackground).then(() => {
Expand Down

0 comments on commit 4ae608f

Please sign in to comment.