diff --git a/modules/core/js_modules/Hm_MessagesStore.js b/modules/core/js_modules/Hm_MessagesStore.js index c299fcdbd..4d5b252e4 100644 --- a/modules/core/js_modules/Hm_MessagesStore.js +++ b/modules/core/js_modules/Hm_MessagesStore.js @@ -70,7 +70,7 @@ class Hm_MessagesStore { */ markRowAsRead(uid) { const rows = Object.entries(this.rows); - const row = this.#getRowByUid(uid)?.value; + const row = this.getRowByUid(uid)?.value; if (row) { const htmlRow = $(row[1]['0']); @@ -96,7 +96,7 @@ class Hm_MessagesStore { */ getNextRowForMessage(uid) { const rows = Object.entries(this.rows); - const row = this.#getRowByUid(uid)?.index; + const row = this.getRowByUid(uid)?.index; if (row !== false) { const nextRow = rows[row + 1]; @@ -114,7 +114,7 @@ class Hm_MessagesStore { */ getPreviousRowForMessage(uid) { const rows = Object.entries(this.rows); - const row = this.#getRowByUid(uid)?.index; + const row = this.getRowByUid(uid)?.index; if (row) { const previousRow = rows[row - 1]; if (previousRow) { @@ -126,7 +126,7 @@ class Hm_MessagesStore { removeRow(uid) { const rows = Object.entries(this.rows); - const row = this.#getRowByUid(uid); + const row = this.getRowByUid(uid); if (row) { const newRows = rows.filter((_, i) => i !== row.index); this.rows = Object.fromEntries(newRows); @@ -226,7 +226,7 @@ class Hm_MessagesStore { * @param {String} uid * @returns {RowOutput|false} row - The row object if found, false otherwise */ - #getRowByUid(uid) { + getRowByUid(uid) { const rows = Object.entries(this.rows); const row = rows.find(([key, value]) => $(value['0']).attr('data-uid') == uid); diff --git a/modules/core/js_modules/route_handlers.js b/modules/core/js_modules/route_handlers.js index 5f62d1cec..4202cd8fe 100644 --- a/modules/core/js_modules/route_handlers.js +++ b/modules/core/js_modules/route_handlers.js @@ -21,15 +21,16 @@ function applyServersPageHandlers() { if (window.wpServersPageHandler) wpServersPageHandler(); } -function applySettingsPageHandlers() { - Hm_Utils.expand_core_settings(); +function applySettingsPageHandlers(routeParams, hash) { + if (hash) { + Hm_Utils.toggle_page_section(`.${hash}`); + } + $('.settings_subtitle').on("click", function() { return Hm_Utils.toggle_page_section($(this).data('target')); }); $('.reset_default_value_checkbox').on("click", reset_default_value_checkbox); $('.reset_default_value_select').on("click", reset_default_value_select); $('.reset_default_value_input').on("click", reset_default_value_input); $('.reset_default_timezone').on("click", reset_default_timezone); - - if (window.expand_feed_settings) expand_feed_settings(); if (window.smtpSettingsPageHandler) smtpSettingsPageHandler(); } @@ -53,6 +54,11 @@ function applyInfoPageHandlers() { if (window.github_repo_update) github_repo_update(); }, 100); + $('.config_map_page').on("click", function() { + var target = $(this).data('target'); + $('.'+target).toggle(); + }); + return () => { clearTimeout(timer); } diff --git a/modules/core/navigation/navigation.js b/modules/core/navigation/navigation.js index 8321efd8d..7f7428e77 100644 --- a/modules/core/navigation/navigation.js +++ b/modules/core/navigation/navigation.js @@ -85,14 +85,15 @@ async function navigate(url) { function renderPage(href) { window.dispatchEvent(new CustomEvent('page-change')); - const searchParams = new URL(href, window.location.origin).searchParams; + const url = new URL(href, window.location.origin); + const searchParams = url.searchParams; const page = searchParams.get('page'); if (page) { const route = ROUTES.find(route => route.page === page); const routeParams = Object.fromEntries(searchParams.entries()); if (route) { - const unMountCallback = route.handler(routeParams); + const unMountCallback = route.handler(routeParams, url.hash?.substring(1)); return unMountCallback; } } diff --git a/modules/core/site.js b/modules/core/site.js index c27a92081..96a0aed50 100644 --- a/modules/core/site.js +++ b/modules/core/site.js @@ -1142,7 +1142,6 @@ var Hm_Folders = { Hm_Folders.update_folder_list(); sessionStorage.clear(); Hm_Utils.restore_local_settings(ui_state); - Hm_Utils.expand_core_settings(); return true; } return false; @@ -1429,41 +1428,6 @@ var Hm_Utils = { return false; }, - expand_core_settings: function() { - var sections = Hm_Utils.get_core_settings(); - var key; - var dsp; - for (key in sections) { - dsp = sections[key]; - if (!dsp) { - dsp = 'none'; - } - $(key).css('display', dsp); - Hm_Utils.save_to_local_storage(key, dsp); - } - }, - - get_core_settings: function() { - var dsp; - var results = {} - var i; - var hash = window.location.hash; - var sections = ['.wp_notifications_setting', '.github_all_setting', '.tfa_setting', '.sent_setting', '.general_setting', '.unread_setting', '.flagged_setting', '.all_setting', '.email_setting', '.junk_setting', '.trash_setting', '.drafts_setting','.tag_setting']; - for (i=0;iout('snoozed_messages', $snoozed_messages); - if ($snoozed_messages == count($ids)) { + if (count($snoozed_messages) == count($ids)) { $msg = 'Messages snoozed'; - } elseif ($snoozed_messages > 0) { + } elseif (count($snoozed_messages) > 0) { $msg = 'Some messages have been snoozed'; } else { $msg = 'ERRFailed to snooze selected messages'; diff --git a/modules/imap/hm-imap.php b/modules/imap/hm-imap.php index dba860da4..5546f9ffe 100644 --- a/modules/imap/hm-imap.php +++ b/modules/imap/hm-imap.php @@ -1892,11 +1892,14 @@ public function append_feed($string) { */ public function append_end() { $result = $this->get_response(false, true); - $uid = $result[0][5]; if ($this->check_response($result, true)) { - return $uid; + $res = preg_grep('/APPENDUID/', array_map('json_encode', $result)); + if ($res) { + $line = json_decode(reset($res), true); + return $line[5]; + } } - return false; + return $result; } /* ------------------ HELPERS ------------------------------------------ */ diff --git a/modules/imap/setup.php b/modules/imap/setup.php index 622d9f1f4..0aab24b11 100644 --- a/modules/imap/setup.php +++ b/modules/imap/setup.php @@ -369,7 +369,7 @@ 'imap_delete_error' => array(FILTER_VALIDATE_BOOLEAN, false), 'move_count' => array(FILTER_DEFAULT, FILTER_REQUIRE_ARRAY), 'show_pagination_links' => array(FILTER_VALIDATE_BOOLEAN, false), - 'snoozed_messages' => array(FILTER_VALIDATE_INT, false), + 'snoozed_messages' => array(FILTER_DEFAULT, FILTER_REQUIRE_ARRAY), 'auto_advance_email_enabled' => array(FILTER_VALIDATE_BOOLEAN, false), 'do_not_flag_as_read_on_open' => array(FILTER_VALIDATE_BOOLEAN, false), 'ajax_imap_folders_permissions' => array(FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY), diff --git a/modules/imap/site.js b/modules/imap/site.js index f974d4f87..d7e7b404e 100644 --- a/modules/imap/site.js +++ b/modules/imap/site.js @@ -367,8 +367,24 @@ var remove_from_cached_imap_pages = function(msg_cache_key) { async function select_imap_folder(path, reload, processInTheBackground = false, abortController = null) { const messages = new Hm_MessagesStore(path, Hm_Utils.get_url_page_number(), null, abortController); - await messages.load(reload, processInTheBackground).then(() => { - display_imap_mailbox(messages.rows, messages.links, path); + await messages.load(reload, processInTheBackground).then(() => { + if (processInTheBackground) { + for (const index in messages.rows) { + const row = messages.rows[index][0]; + const rowUid = $(row).data('uid'); + const rowExist = Hm_Utils.tbody().find(`tr[data-uid="${rowUid}"]`).length; + if (!rowExist) { + Hm_Utils.rows().eq(index).before(row); + }; + } + Hm_Utils.rows().each(function() { + if (!messages.getRowByUid($(this).data('uid'))) { + $(this).remove(); + } + }); + } else { + display_imap_mailbox(messages.rows, messages.links); + } }); if (path === 'unread') { @@ -397,7 +413,6 @@ var setup_imap_folder_page = async function(listPath) { $('.imap_keyword').on('search', function() { $('#imap_filter_form').trigger('submit'); }); - Hm_Ajax.add_callback_hook('ajax_message_action', function() { select_imap_folder(listPath, true); }); const hadLocalData = new Hm_MessagesStore(listPath, Hm_Utils.get_url_page_number()).hasLocalData(); await select_imap_folder(listPath); @@ -433,7 +448,8 @@ $('#imap_filter_form').on('submit', async function(event) { } }); -var display_imap_mailbox = function(rows, links, path = getListPathParam()) { +var display_imap_mailbox = function(rows, links) { + Hm_Message_List.toggle_msg_controls(); if (rows) { Hm_Message_List.update(rows); Hm_Message_List.check_empty_list(); @@ -844,16 +860,11 @@ var search_selected_for_imap = function() { }; var unselect_non_imap_messages = function() { - var unselected = 0; - $('input[type=checkbox]').each(function() { + $('.message_table_body .checkbox_cell input[type=checkbox]').each(function() { if (this.checked && this.id.search('imap') == -1) { this.checked = false; - unselected++; } }); - if (unselected > 0) { - Hm_Notices.show({0: 'ERR'+$('.move_to_string3').val()}); - } }; var imap_move_copy = function(e, action, context) { @@ -1081,11 +1092,11 @@ var imap_setup_snooze = function() { $(document).on('click', '.snooze_date_picker', function(e) { document.querySelector('.snooze_input_date').showPicker(); }); - $(document).on('click', '.snooze_helper', function(e) { + $('.snooze_helper').on('click', function(e) { e.preventDefault(); $('.snooze_input').val($(this).attr('data-value')).trigger('change'); }); - $(document).on('input', '.snooze_input_date', function(e) { + $('.snooze_input_date').on('input', function(e) { var now = new Date(); now.setMinutes(now.getMinutes() + 1); $(this).attr('min', now.toJSON().slice(0, 16)); @@ -1095,12 +1106,12 @@ var imap_setup_snooze = function() { $('.snooze_date_picker').css({'border': 'unset', 'border-top': '1px solid #ddd'}); } }); - $(document).on('change', '.snooze_input_date', function(e) { + $('.snooze_input_date').on('change', function(e) { if ($(this).val() && new Date().getTime() < new Date($(this).val()).getTime()) { $('.snooze_input').val($(this).val()).trigger('change'); } }); - $(document).on('change', '.snooze_input', function(e) { + $('.snooze_input').on('change', function(e) { $('.snooze_dropdown').hide(); var ids = []; if (getPageNameParam() == 'message') { @@ -1121,11 +1132,21 @@ var imap_setup_snooze = function() { [{'name': 'hm_ajax_hook', 'value': 'ajax_imap_snooze'}, {'name': 'imap_snooze_ids', 'value': ids}, {'name': 'imap_snooze_until', 'value': $(this).val()}], - function(res) { - if (res.snoozed_messages > 0) { + async function(res) { + const snoozedMessages = Object.values(res['snoozed_messages']); + if (snoozedMessages.length) { + const path = getParam("list_parent") || getListPathParam(); + const store = new Hm_MessagesStore(path, Hm_Utils.get_url_page_number()); + await store.load(false, true, true); + + snoozedMessages.forEach((msg) => { + store.removeRow(msg); + }); + if (getPageNameParam() == 'message_list') { + display_imap_mailbox(store.rows, store.links, getListPathParam()); + } + Hm_Folders.reload_folders(true); - var path = hm_list_parent()? hm_list_parent(): getListPathParam(); - window.location.replace('?page=message_list&list_path='+path); } } ); diff --git a/tests/selenium/send.py b/tests/selenium/send.py index c1816231a..4c96354e5 100644 --- a/tests/selenium/send.py +++ b/tests/selenium/send.py @@ -14,6 +14,7 @@ def __init__(self): def load_compose_page(self): self.load() + self.wait_on_class('menu_compose') list_item = self.by_class('menu_compose') link = list_item.find_element(By.TAG_NAME, 'a').click() self.wait_with_folder_list()