Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow: Move the top of narrow notices to `message_scroll.js`.
Ryan Rehmanc7e39ef09081
diff --git a/frontend_tests/node_tests/message_fetch.js b/frontend_tests/node_tests/message_fetch.jsindex 8b499c026fb..8571e13902a 100644--- a/frontend_tests/node_tests/message_fetch.js+++ b/frontend_tests/node_tests/message_fetch.js@@ -30,13 +30,11 @@ set_global('message_scroll', {hide_loading_older: noop,show_loading_newer: noop,hide_loading_newer: noop,+ update_top_of_narrow_notices: () => {},});set_global('message_util', {});set_global('message_store', {});set_global('narrow_state', {});-set_global('notifications', {- update_top_of_narrow_notices: () => {},-});set_global('pm_list', {});set_global('server_events', {});set_global('stream_list', {diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.jsindex f6cbd750194..8345d6e17ec 100644--- a/frontend_tests/node_tests/narrow_activate.js+++ b/frontend_tests/node_tests/narrow_activate.js@@ -75,6 +75,7 @@ function test_helper() {stub('hashchange', 'save_narrow');stub('message_scroll', 'hide_indicators');stub('message_scroll', 'show_loading_older');+ stub('message_scroll', 'hide_top_of_narrow_notices');stub('notifications', 'clear_compose_notifications');stub('notifications', 'redraw_title');stub('search', 'update_button_visibility');@@ -86,8 +87,6 @@ function test_helper() {stub('unread_ops', 'process_visible');stub('compose', 'update_closed_compose_buttons_for_stream');stub('compose', 'update_closed_compose_buttons_for_private');- stub('notifications', 'hide_history_limit_notice');- stub('notifications', 'hide_end_of_results_notice');return {clear: () => {@@ -201,8 +200,7 @@ run_test('basics', () => {helper.assert_events(['notifications.clear_compose_notifications','notifications.redraw_title',- 'notifications.hide_history_limit_notice',- 'notifications.hide_end_of_results_notice',+ 'message_scroll.hide_top_of_narrow_notices','message_scroll.hide_indicators','ui_util.change_tab_to','unread_ops.process_visible',diff --git a/static/js/message_fetch.js b/static/js/message_fetch.jsindex 0050bdd710c..f1e62788de3 100644--- a/static/js/message_fetch.js+++ b/static/js/message_fetch.js@@ -79,7 +79,7 @@ function get_messages_success(data, opts) {history_limited: data.history_limited,});}- notifications.update_top_of_narrow_notices(opts.msg_list);+ message_scroll.update_top_of_narrow_notices(opts.msg_list);}if (opts.num_after > 0) {diff --git a/static/js/message_scroll.js b/static/js/message_scroll.jsindex c386019ad5e..fc1341be9a3 100644--- a/static/js/message_scroll.js+++ b/static/js/message_scroll.js@@ -41,6 +41,65 @@ exports.hide_indicators = function () {exports.hide_loading_newer();};+exports.show_history_limit_notice = function () {+ $(".top-messages-logo").hide();+ $(".history-limited-box").show();+ exports.hide_empty_narrow_message();+};++exports.hide_history_limit_notice = function () {+ $(".top-messages-logo").show();+ $(".history-limited-box").hide();+};++exports.hide_end_of_results_notice = function () {+ $(".all-messages-search-caution").hide();+};++exports.show_end_of_results_notice = function () {+ $(".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/")+ );+};++exports.update_top_of_narrow_notices = function (msg_list) {+ // Assumes that the current state is all notices hidden (i.e. this+ // will not hide a notice that should not be there)+ if (msg_list !== current_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()) {+ exports.show_end_of_results_notice();+ }+ }++ if (msg_list.data.fetch_status.history_limited()) {+ exports.show_history_limit_notice();+ }+};++exports.hide_top_of_narrow_notices = function () {+ exports.hide_end_of_results_notice();+ exports.hide_history_limit_notice();+};+exports.actively_scrolling = function () {return actively_scrolling;};diff --git a/static/js/narrow.js b/static/js/narrow.jsindex 21374f25cba..e1c6d13aa68 100644--- a/static/js/narrow.js+++ b/static/js/narrow.js@@ -148,8 +148,7 @@ exports.activate = function (raw_operators, opts) {const operators = filter.operators();update_narrow_title(filter);- notifications.hide_history_limit_notice();- notifications.hide_end_of_results_notice();+ message_scroll.hide_top_of_narrow_notices();message_scroll.hide_indicators();blueslip.debug("Narrowed", {operators: operators.map(e => e.operator),@@ -754,8 +753,8 @@ function handle_post_narrow_deactivate_processes() {tab_bar.initialize();exports.narrow_title = "home";notifications.redraw_title();- notifications.update_top_of_narrow_notices(home_msg_list);- notifications.hide_end_of_results_notice();+ message_scroll.hide_top_of_narrow_notices();+ message_scroll.update_top_of_narrow_notices(home_msg_list);}exports.deactivate = function () {diff --git a/static/js/notifications.js b/static/js/notifications.jsindex 157f3b0c91d..93b83bd6722 100644--- a/static/js/notifications.js+++ b/static/js/notifications.js@@ -171,60 +171,6 @@ exports.redraw_title = function () {}};-exports.show_history_limit_notice = function () {- $(".top-messages-logo").hide();- $(".history-limited-box").show();- narrow.hide_empty_narrow_message();-};--exports.hide_history_limit_notice = function () {- $(".top-messages-logo").show();- $(".history-limited-box").hide();-};--exports.hide_end_of_results_notice = function () {- $(".all-messages-search-caution").hide();-};--exports.show_end_of_results_notice = function () {- $(".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/")- );-};--exports.update_top_of_narrow_notices = function (msg_list) {- if (msg_list !== current_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()) {- exports.show_end_of_results_notice();- }- }-- if (msg_list.data.fetch_status.history_limited()) {- exports.show_history_limit_notice();- } else {- exports.hide_history_limit_notice();- }-};-function flash_pms() {// When you have unread PMs, toggle the favicon between the unread count and// a special icon indicating that you have unread PMs.