Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

minor: Refactor the top of narrow notices.

Ryan Rehman542a3dea7763
diff --git a/frontend_tests/node_tests/message_fetch.js b/frontend_tests/node_tests/message_fetch.js
index fa490682bc1..a86807406c5 100644
--- a/frontend_tests/node_tests/message_fetch.js
+++ b/frontend_tests/node_tests/message_fetch.js
@@ -33,7 +33,7 @@ set_global('message_util', {});
set_global('message_store', {});
set_global('narrow_state', {});
set_global('notifications', {
- hide_or_show_history_limit_message: () => {},
+ update_top_of_narrow_notices: () => {},
});
set_global('pm_list', {});
set_global('server_events', {});
diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.js
index 58aa8ae33ef..062aefd3bae 100644
--- a/frontend_tests/node_tests/narrow_activate.js
+++ b/frontend_tests/node_tests/narrow_activate.js
@@ -86,7 +86,8 @@ 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_message');
+ stub('notifications', 'hide_history_limit_notice');
+ stub('notifications', 'hide_end_of_results_notice');
return {
clear: () => {
@@ -200,7 +201,8 @@ run_test('basics', () => {
helper.assert_events([
'notifications.clear_compose_notifications',
'notifications.redraw_title',
- 'notifications.hide_history_limit_message',
+ 'notifications.hide_history_limit_notice',
+ 'notifications.hide_end_of_results_notice',
'ui_util.change_tab_to',
'message_scroll.hide_indicators',
'unread_ops.process_visible',
diff --git a/static/js/message_fetch.js b/static/js/message_fetch.js
index 6a34dd2962f..6522d19a71d 100644
--- a/static/js/message_fetch.js
+++ b/static/js/message_fetch.js
@@ -72,7 +72,7 @@ function get_messages_success(data, opts) {
history_limited: data.history_limited,
});
}
- notifications.hide_or_show_history_limit_message(opts.msg_list);
+ notifications.update_top_of_narrow_notices(opts.msg_list);
}
if (opts.num_after > 0) {
diff --git a/static/js/narrow.js b/static/js/narrow.js
index 7873237d056..1df6402dda9 100644
--- a/static/js/narrow.js
+++ b/static/js/narrow.js
@@ -148,8 +148,8 @@ exports.activate = function (raw_operators, opts) {
const operators = filter.operators();
update_narrow_title(filter);
- notifications.hide_history_limit_message();
- $(".all-messages-search-caution").hide();
+ notifications.hide_history_limit_notice();
+ notifications.hide_end_of_results_notice();
blueslip.debug("Narrowed", {operators: operators.map(e => e.operator),
trigger: opts ? opts.trigger : undefined,
@@ -756,8 +756,8 @@ function handle_post_narrow_deactivate_processes() {
tab_bar.initialize();
exports.narrow_title = "home";
notifications.redraw_title();
- notifications.hide_or_show_history_limit_message(home_msg_list);
- $(".all-messages-search-caution").hide();
+ notifications.update_top_of_narrow_notices(home_msg_list);
+ notifications.hide_end_of_results_notice();
}
exports.deactivate = function () {
diff --git a/static/js/notifications.js b/static/js/notifications.js
index e18f0f31f90..157f3b0c91d 100644
--- a/static/js/notifications.js
+++ b/static/js/notifications.js
@@ -171,18 +171,33 @@ exports.redraw_title = function () {
}
};
-exports.show_history_limit_message = function () {
+exports.show_history_limit_notice = function () {
$(".top-messages-logo").hide();
$(".history-limited-box").show();
narrow.hide_empty_narrow_message();
};
-exports.hide_history_limit_message = function () {
+exports.hide_history_limit_notice = function () {
$(".top-messages-logo").show();
$(".history-limited-box").hide();
};
-exports.hide_or_show_history_limit_message = function (msg_list) {
+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;
}
@@ -199,21 +214,14 @@ exports.hide_or_show_history_limit_message = function (msg_list) {
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/")
- );
+ exports.show_end_of_results_notice();
}
}
if (msg_list.data.fetch_status.history_limited()) {
- exports.show_history_limit_message();
+ exports.show_history_limit_notice();
} else {
- exports.hide_history_limit_message();
+ exports.hide_history_limit_notice();
}
};