Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mr 1266 c #4

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7e1a1dd
Implement browser history API based navigation, preventing browser re…
mercihabam Oct 2, 2024
1385105
A couple of fixes and refinements to the navigation module ensuring t…
mercihabam Oct 3, 2024
e7e3fa3
Apply servers and settings page handlers
mercihabam Oct 3, 2024
8ff0a0b
Apply handlers on page load as well
mercihabam Oct 3, 2024
36593d4
Update the sidebar item's active state when navigating
mercihabam Oct 4, 2024
a252ab6
Fix displaying the message content with the correct route params
mercihabam Oct 4, 2024
bf2bff9
Move entire imap_folder_page_setup the the message list route handler
mercihabam Oct 4, 2024
aebb929
Fix refresh links
mercihabam Oct 4, 2024
0fc096b
Fix sorting and filtering of messages
mercihabam Oct 5, 2024
2e9f204
imap unread handler: allow fetching the messages from the connected s…
mercihabam Oct 7, 2024
f9b025b
Hm_MessagesStore supports combined unread folder
mercihabam Oct 7, 2024
2dfc14d
Avoid an endless loop of request callbacks
mercihabam Oct 7, 2024
6eb9367
Load customized folders' content upon navigation
mercihabam Oct 7, 2024
0bd2d8d
Flagged contents are displayed
mercihabam Oct 8, 2024
a90150c
Combined inbox contents are displayed
mercihabam Oct 8, 2024
c06292d
Output correct server ids
mercihabam Oct 8, 2024
0ea4c94
Avoid fetching with the previous page href
mercihabam Oct 8, 2024
a7be3b9
Refresh the message list in the backround on page load if the store h…
mercihabam Oct 8, 2024
c0041b2
Add a process to refresh the active message list in the background
mercihabam Oct 8, 2024
477e6b1
Move Hm_MessagesStore to the core module, and move some remanants cod…
mercihabam Oct 9, 2024
8f73017
Final move of the remnants of the code previously handled by hm_list_…
mercihabam Oct 10, 2024
1b61f46
Ensure the unmount callback is regularlly called whenever a page loos…
mercihabam Oct 10, 2024
8b76d0b
Abort background processes relative to a page when it's unmounted
mercihabam Oct 10, 2024
e9565df
Automate the page_js_debug test to include all given js files in the …
mercihabam Oct 11, 2024
a2c27c0
selenium test debug
mercihabam Oct 16, 2024
645d414
test debug
mercihabam Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Load customized folders' content upon navigation
mercihabam authored and josaphatim committed Oct 16, 2024
commit 6eb9367f00aa2a953ff7f6b2cc87b22373de89f9
24 changes: 13 additions & 11 deletions modules/core/site.js
Original file line number Diff line number Diff line change
@@ -289,17 +289,19 @@ var Hm_Ajax_Request = function() { return {
Hm_Notices.show(res.router_user_msgs);
}
if (res.folder_status) {
for (var name in res.folder_status) {
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());
messages.load().then(() => {
if (messages.count != res.folder_status[name].messages) {
messages.load(true).then(() => {
display_imap_mailbox(messages.rows, messages.links);
})
}
});
for (const name in res.folder_status) {
if (name === getPageNameParam()) {
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());
messages.load().then(() => {
if (messages.count != res.folder_status[name].messages) {
messages.load(true).then(() => {
display_imap_mailbox(messages.rows, messages.links);
})
}
});
}
}
}
if (this.callback) {
40 changes: 24 additions & 16 deletions modules/imap/handler_modules.php
Original file line number Diff line number Diff line change
@@ -2197,20 +2197,26 @@ class Hm_Handler_imap_folder_data extends Hm_Handler_Module {
public function process() {
list($success, $form) = $this->process_form(array('imap_server_ids'));
if ($success) {
$path = $this->request->get['list_path'];
$limit = $this->user_config->get($path.'_per_source_setting', DEFAULT_PER_SOURCE);
$date = process_since_argument($this->user_config->get($path.'_since_setting', DEFAULT_UNREAD_SINCE));
$ids = explode(',', $form['imap_server_ids']);
} else {
$data_sources = imap_sources('', $this, $this->request->get['list_path']);
$ids = array_map(function($ds) { return $ds['id']; }, $data_sources);
$folders = array_map(function($ds) { return $ds['folder']; }, $data_sources);
}
$path = $this->request->get['list_path'];
$limit = $this->user_config->get($path.'_per_source_setting', DEFAULT_PER_SOURCE);
$date = process_since_argument($this->user_config->get($path.'_since_setting', DEFAULT_UNREAD_SINCE));
if (! isset($folders) || empty($folders)) {
$folder = bin2hex('INBOX');
if (array_key_exists('folder', $this->request->post)) {
$folder = $this->request->post['folder'];
}
if (hex2bin($folder) == 'SPECIAL_USE_CHECK' || hex2bin($folder) == 'INBOX') {
list($status, $msg_list) = merge_imap_search_results($ids, 'ALL', $this->session, $this->cache, array(hex2bin($folder)), $limit, array(array('SINCE', $date)), true);
}
else {
} else {
list($status, $msg_list) = merge_imap_search_results($ids, 'ALL', $this->session, $this->cache, array(hex2bin($folder)), $limit, array(array('SINCE', $date)), false);
}

$folders = array();
foreach ($msg_list as $msg) {
if (hex2bin($msg['folder']) != hex2bin($folder)) {
@@ -2221,18 +2227,20 @@ public function process() {
$auto_folder = $folders[0];
$this->out('auto_'.$path.'_folder', $msg_list[0]['server_name'].' '.$auto_folder);
}
if (array_key_exists('keyword', $this->request->get)) {
$keyword = $this->request->get['keyword'];
$search_pattern = "/$keyword/i";
$search_result = array_filter($msg_list, function($filter_msg_list) use ($search_pattern) {
return preg_grep($search_pattern, $filter_msg_list);
});
$msg_list = $search_result;
}
$this->out('folder_status', $status);
$this->out('imap_'.$path.'_data', $msg_list);
$this->out('imap_server_ids', $form['imap_server_ids']);
} else {
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)), false);
}
if (array_key_exists('keyword', $this->request->get)) {
$keyword = $this->request->get['keyword'];
$search_pattern = "/$keyword/i";
$search_result = array_filter($msg_list, function($filter_msg_list) use ($search_pattern) {
return preg_grep($search_pattern, $filter_msg_list);
});
$msg_list = $search_result;
}
$this->out('folder_status', $status);
$this->out('imap_'.$path.'_data', $msg_list);
$this->out('imap_server_ids', $form['imap_server_ids']);
}
}

8 changes: 7 additions & 1 deletion modules/imap/js_modules/Hm_Message.js
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ class Hm_MessagesStore {

const { formatted_message_list: updatedMessages, page_links: pageLinks, folder_status, do_not_flag_as_read_on_open } = await this.#fetch(hideLoadingState);

this.count = folder_status && Object.values(folder_status)[0].messages;
this.count = folder_status && Object.values(folder_status)[0]?.messages;
this.links = pageLinks;
this.rows = updatedMessages;
this.flagAsReadOnOpen = !do_not_flag_as_read_on_open;
@@ -141,6 +141,12 @@ class Hm_MessagesStore {
case 'unread':
hook = "ajax_imap_unread";
break;
case 'flagged':
hook = "ajax_imap_flagged";
break;
default:
hook = "ajax_imap_folder_data";
break;
}
}

2 changes: 0 additions & 2 deletions modules/imap/js_modules/route_handlers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
function applyImapMessageListPageHandlers(routeParams) {
setup_imap_folder_page(routeParams.list_path); // Imap is OK, but other types don't work with this handler yet
// TODO: - Support folders from other sources (Combined, Feeds, and JMAP as well maybe.)

$('.refresh_link').on("click", function() { return Hm_Message_List.load_sources(); });
}

function applyImapMessageContentPageHandlers(routeParams) {
5 changes: 3 additions & 2 deletions modules/imap/site.js
Original file line number Diff line number Diff line change
@@ -454,9 +454,10 @@ var setup_imap_folder_page = function(listPath) {
select_imap_folder(listPath);
$('.remove_source').on("click", remove_imap_combined_source);
$('.add_source').on("click", add_imap_combined_source);
$('.refresh_link').on("click", function() {
$('.refresh_link').on("click", function(e) {
e.preventDefault();
if ($('.imap_keyword').val()) {
$('#imap_filter_form').submit();
$('#imap_filter_form').trigger('submit');
}
else {
select_imap_folder(listPath, true);