Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow: Show streams:all notice only after "oldest" is found.
Ryan Rehmane0b109625399
diff --git a/frontend_tests/node_tests/fetch_status.js b/frontend_tests/node_tests/fetch_status.jsindex 891ebda4faf..581356b6cfd 100644--- a/frontend_tests/node_tests/fetch_status.js+++ b/frontend_tests/node_tests/fetch_status.js@@ -22,6 +22,14 @@ function blocked_older() {assert.equal(fetch_status.can_load_older_messages(), false);}+function has_found_oldest() {+ assert.equal(fetch_status.has_found_oldest(), true);+}++function has_not_found_oldest() {+ assert.equal(fetch_status.has_found_oldest(), false);+}+function has_found_newest() {assert.equal(fetch_status.has_found_newest(), true);}@@ -47,6 +55,7 @@ run_test('basics', () => {blocked_newer();blocked_older();can_load_history();+ has_not_found_oldest();has_not_found_newest();let data = {@@ -57,6 +66,7 @@ run_test('basics', () => {fetch_status.finish_newer_batch(data);fetch_status.finish_older_batch(data);+ has_found_oldest();has_found_newest();blocked_newer();blocked_older();diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.jsindex 0afc59dceb8..58aa8ae33ef 100644--- a/frontend_tests/node_tests/narrow_activate.js+++ b/frontend_tests/node_tests/narrow_activate.js@@ -179,15 +179,12 @@ run_test('basics', () => {};let cont;- let pre_scroll_cont;message_fetch.load_messages_for_narrow = (opts) => {cont = opts.cont;- pre_scroll_cont = opts.pre_scroll_cont;assert.deepEqual(opts, {cont: opts.cont,- pre_scroll_cont: opts.pre_scroll_cont,anchor: 1000,});};@@ -233,7 +230,6 @@ run_test('basics', () => {};helper.clear();- pre_scroll_cont();cont();helper.assert_events(['report narrow times',diff --git a/static/js/fetch_status.js b/static/js/fetch_status.jsindex fb59ed67231..830d1f24a05 100644--- a/static/js/fetch_status.js+++ b/static/js/fetch_status.js@@ -22,6 +22,10 @@ const FetchStatus = function () {return !loading_older && !found_oldest;};+ self.has_found_oldest = function () {+ return found_oldest;+ };+self.history_limited = function () {return history_limited;};diff --git a/static/js/message_fetch.js b/static/js/message_fetch.jsindex 6700caefdd5..6a34dd2962f 100644--- a/static/js/message_fetch.js+++ b/static/js/message_fetch.js@@ -53,10 +53,6 @@ function process_result(data, opts) {pm_list.update_private_messages();recent_topics.process_messages(messages);- if (opts.pre_scroll_cont !== undefined) {- opts.pre_scroll_cont(data);- }-stream_list.maybe_scroll_narrow_into_view();if (opts.cont !== undefined) {@@ -225,7 +221,6 @@ exports.load_messages_for_narrow = function (opts) {num_before: consts.narrow_before,num_after: consts.narrow_after,msg_list: msg_list,- pre_scroll_cont: opts.pre_scroll_cont,cont: function () {message_scroll.hide_indicators();opts.cont();diff --git a/static/js/narrow.js b/static/js/narrow.jsindex 06eda2bfcf7..7873237d056 100644--- a/static/js/narrow.js+++ b/static/js/narrow.js@@ -290,26 +290,6 @@ exports.activate = function (raw_operators, opts) {msg_list.network_time = new Date();maybe_report_narrow_time(msg_list);},- pre_scroll_cont: function () {- // Potentially display the notice that lets users know- // that not all messages were searched. One could- // imagine including `filter.is_search()` in these- // conditions, but there's a very legitimate use case- // for moderation of searching for all messages sent- // by a potential spammer user.- if (!filter.contains_only_private_messages() &&- !filter.includes_full_stream_history() &&- !filter.is_personal_filter()) {- $(".all-messages-search-caution").show();- // Set the link to point to this search with streams:public added.- // It's a bit hacky to use the href, but- // !filter.includes_full_stream_history() implies streams:public- // wasn't already present.- $(".all-messages-search-caution a.search-shared-history").attr(- "href", window.location.hash.replace("#narrow/", "#narrow/streams/public/")- );- }- },});}());diff --git a/static/js/notifications.js b/static/js/notifications.jsindex 1b5ff98ed1a..e18f0f31f90 100644--- a/static/js/notifications.js+++ b/static/js/notifications.js@@ -187,6 +187,29 @@ exports.hide_or_show_history_limit_message = function (msg_list) {return;}+ if (msg_list.data.fetch_status.has_found_oldest() &&+ current_msg_list !== home_msg_list) {+ const filter = narrow_state.filter();+ // Potentially display the notice that lets users know+ // that not all messages were searched. One could+ // imagine including `filter.is_search()` in these+ // conditions, but there's a very legitimate use case+ // for moderation of searching for all messages sent+ // by a potential spammer user.+ if (!filter.contains_only_private_messages() &&+ !filter.includes_full_stream_history() &&+ !filter.is_personal_filter()) {+ $(".all-messages-search-caution").show();+ // Set the link to point to this search with streams:public added.+ // It's a bit hacky to use the href, but+ // !filter.includes_full_stream_history() implies streams:public+ // wasn't already present.+ $(".all-messages-search-caution a.search-shared-history").attr(+ "href", window.location.hash.replace("#narrow/", "#narrow/streams/public/")+ );+ }+ }+if (msg_list.data.fetch_status.history_limited()) {exports.show_history_limit_message();} else {