This is an automated email from the ASF dual-hosted git repository. humbedooh pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit f7e30e1e36fe423a2b19b4e147d0650a9f256d65 Author: Daniel Gruno <[email protected]> AuthorDate: Sat Nov 13 17:41:30 2021 +0100 regen JS --- webui/js/ponymail.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/webui/js/ponymail.js b/webui/js/ponymail.js index 5fabacc..bd0e049 100644 --- a/webui/js/ponymail.js +++ b/webui/js/ponymail.js @@ -278,6 +278,15 @@ Array.prototype.has = function(val) { return false; }; +Object.prototype.isEmpty = function() { + return ( + this + && Object.keys(this).length === 0 + && Object.getPrototypeOf(this) === Object.prototype + ) +} + + /****************************************** Fetched from source/body-fixups.js ******************************************/ @@ -2163,13 +2172,17 @@ let current_index_pos = 0; let current_per_page = 0; function listview_header(state, json) { + if (json.isEmpty()) { // Bad search request? + modal("Bad search request", "Your request could not be parsed.", "warning"); + return; + } let list_title = json.list; prev_listview_json = json; prev_listview_state = state; if (current_list == 'virtual' && current_domain == 'inbox') { list_title = "Virtual inbox, past 30 days"; } - let blobs = json.emails || []; + let blobs = json.emails ? json.emails : []; if (current_listmode == 'threaded') blobs = json.thread_struct; if (current_year && current_month) { @@ -2212,8 +2225,9 @@ function listview_header(state, json) { if (state && state.pos) { first = 1 + state.pos; } - if (blobs.length == 0) { + if (!blobs || blobs.length == 0) { chevrons.innerHTML = "No topics to show"; + blobs = []; } else { chevrons.innerHTML = "Showing <b>%u through %u</b> of <b>%u</b> topics ".format(first, Math.min(first + per_page - 1, blobs.length), blobs.length || 0); }
