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.

left_sidebar: Ensure All messages highlight on reload.

Karl Stolley62f5806f428f
diff --git a/web/src/left_sidebar_navigation_area.js b/web/src/left_sidebar_navigation_area.js
index 5900da49516..6cdbcb67144 100644
--- a/web/src/left_sidebar_navigation_area.js
+++ b/web/src/left_sidebar_navigation_area.js
@@ -68,8 +68,7 @@ export function handle_narrow_activated(filter) {
if (ops.length >= 1) {
filter_name = ops[0];
if (filter_name === "home") {
- $filter_li = $(".top_left_all_messages");
- $filter_li.addClass("active-filter");
+ highlight_all_messages_view();
}
}
ops = filter.operands("is");
@@ -146,6 +145,17 @@ export function highlight_recent_view() {
}, 0);
}
+export function highlight_all_messages_view() {
+ remove($(".top_left_starred_messages"));
+ remove($(".top_left_mentions"));
+ remove($(".top_left_recent_view"));
+ remove($(".top_left_inbox"));
+ $(".top_left_all_messages").addClass("active-filter");
+ setTimeout(() => {
+ resize.resize_stream_filters_container();
+ }, 0);
+}
+
function handle_home_view_order(home_view) {
// Remove class and tabindex from current home view
const $current_home_view = $(".selected-home-view");
diff --git a/web/src/narrow.js b/web/src/narrow.js
index 6f8c30ec745..b90296cd780 100644
--- a/web/src/narrow.js
+++ b/web/src/narrow.js
@@ -58,6 +58,7 @@ import * as util from "./util";
import * as widgetize from "./widgetize";
const LARGER_THAN_MAX_MESSAGE_ID = 10000000000000000;
+export let has_visited_all_messages = false;
export function reset_ui_state() {
// Resets the state of various visual UI elements that are
@@ -988,11 +989,19 @@ export function deactivate(message_feed_previously_hidden = false) {
message_lists.home in it.
*/
search.clear_search_form();
- // Both All messages and Recent Conversations have `undefined` filter.
- // Return if already in the All message narrow.
- if (narrow_state.filter() === undefined && !message_feed_previously_hidden) {
+
+ // If we're already looking at the All messages view, exit without
+ // doing any work.
+ if (
+ narrow_state.filter() === undefined &&
+ !message_feed_previously_hidden &&
+ has_visited_all_messages
+ ) {
return;
}
+
+ has_visited_all_messages = true;
+
blueslip.debug("Unnarrowed");
if (message_scroll_state.actively_scrolling) {
diff --git a/web/tests/left_sidebar_navigation_area.test.js b/web/tests/left_sidebar_navigation_area.test.js
index 697fa936cf4..ecc305f31a2 100644
--- a/web/tests/left_sidebar_navigation_area.test.js
+++ b/web/tests/left_sidebar_navigation_area.test.js
@@ -60,6 +60,13 @@ run_test("narrowing", () => {
assert.ok(!$(".top_left_starred_messages").hasClass("active-filter"));
assert.ok(!$(".top_left_recent_view").hasClass("active-filter"));
assert.ok($(".top_left_inbox").hasClass("active-filter"));
+
+ left_sidebar_navigation_area.highlight_all_messages_view();
+ assert.ok(!$(".top_left_mentions").hasClass("active-filter"));
+ assert.ok(!$(".top_left_starred_messages").hasClass("active-filter"));
+ assert.ok(!$(".top_left_recent_view").hasClass("active-filter"));
+ assert.ok(!$(".top_left_inbox").hasClass("active-filter"));
+ assert.ok($(".top_left_all_messages").hasClass("active-filter"));
});
run_test("update_count_in_dom", () => {