Skip to content

Commit

Permalink
Sort combined messages list chronologically and adjust the tagged mes…
Browse files Browse the repository at this point in the history
…sages request and handler (#1329)

* Sort the combined list of messages by date rather than by the mailbox

* Ensure tagged messages are requested with correct inputs
  • Loading branch information
jacob-js authored Nov 9, 2024
1 parent 1d045c9 commit a4c136d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions modules/core/js_modules/Hm_MessagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ class Hm_MessagesStore {
case 'email':
hook = "ajax_imap_combined_inbox";
break;
case 'tag':
hook = "ajax_imap_tag_data";
folder = getParam('tag_id');
break;
default:
hook = "ajax_imap_folder_data";
break;
Expand Down
5 changes: 5 additions & 0 deletions modules/imap/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,11 @@ public function process() {
$date = process_since_argument($this->user_config->get('all_since_setting', DEFAULT_ALL_SINCE));
}
list($status, $msg_list) = merge_imap_search_results($ids, 'ALL', $this->session, $this->cache, array_map(fn ($folder) => hex2bin($folder), $folders), $limit, array(array('SINCE', $date)));

usort($msg_list, function($a, $b) {
return strtotime($b['internal_date']) - strtotime($a['internal_date']);
});

$this->out('folder_status', $status);
$this->out('imap_combined_inbox_data', $msg_list);
$this->out('imap_server_ids', implode(',', $ids));
Expand Down
10 changes: 5 additions & 5 deletions modules/tags/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,20 @@ public function process() {
*/
class Hm_Handler_imap_tag_content extends Hm_Handler_Module {
public function process() {
list($success, $form) = $this->process_form(array('imap_server_ids'));
if ($success) {
$data_sources = imap_data_sources('');
$ids = array_map(function($ds) { return $ds['id']; }, $data_sources);
$tag_id = $this->request->post['folder'];
if ($ids && $tag_id) {
$limit = $this->user_config->get('tag_per_source_setting', DEFAULT_TAGS_PER_SOURCE);
$date = process_since_argument($this->user_config->get('tag_since_setting', DEFAULT_TAGS_SINCE));
$tag_id = $this->request->get['tag_id'];
$ids = explode(',', $form['imap_server_ids']);
$folder = bin2hex('INBOX');
if (array_key_exists('folder', $this->request->post)) {
$folder = $this->request->post['folder'];
}
list($status, $msg_list) = merge_imap_search_results($ids, 'ALL', $this->session, $this->cache, array(hex2bin($folder)), $limit, array(array('SINCE', $date), array('HEADER X-Cypht-Tags', $tag_id)));
$this->out('folder_status', $status);
$this->out('imap_tag_data', $msg_list);
$this->out('imap_server_ids', $form['imap_server_ids']);
$this->out('imap_server_ids', implode(',', $ids));
}
}
}
Expand Down

0 comments on commit a4c136d

Please sign in to comment.