From 20b2323c679307596c565e0745706a889e090a8e Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 3 Oct 2023 17:52:04 -0700 Subject: [PATCH] left_sidebar: Deduplicate handle_narrow_deactivated. handle_narrow_activated did the same thing is passed the home_msg_list filter. --- web/src/left_sidebar_navigation_area.js | 7 ------- web/src/narrow.js | 3 +-- web/tests/left_sidebar_navigation_area.test.js | 6 +++--- web/tests/narrow_activate.test.js | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/web/src/left_sidebar_navigation_area.js b/web/src/left_sidebar_navigation_area.js index c05c98ffc4..49381b41de 100644 --- a/web/src/left_sidebar_navigation_area.js +++ b/web/src/left_sidebar_navigation_area.js @@ -81,13 +81,6 @@ export function handle_narrow_activated(filter) { } } -export function handle_narrow_deactivated() { - deselect_top_left_corner_items(); - - const $filter_li = $(".top_left_all_messages"); - $filter_li.addClass("active-filter"); -} - export function highlight_recent_view() { remove($(".top_left_all_messages")); remove($(".top_left_starred_messages")); diff --git a/web/src/narrow.js b/web/src/narrow.js index e194e44c9d..98f5f641ea 100644 --- a/web/src/narrow.js +++ b/web/src/narrow.js @@ -561,7 +561,6 @@ export function activate(raw_operators, opts) { const current_filter = narrow_state.filter(); - left_sidebar_navigation_area.handle_narrow_activated(current_filter); pm_list.handle_narrow_activated(current_filter); stream_list.handle_narrow_activated(current_filter); unread_ui.update_unread_banner(); @@ -1021,6 +1020,7 @@ function handle_post_view_change(msg_list) { message_view_header.render_title_area(); update_narrow_title(filter); + left_sidebar_navigation_area.handle_narrow_activated(filter); } function handle_post_narrow_deactivate_processes(msg_list) { @@ -1028,7 +1028,6 @@ function handle_post_narrow_deactivate_processes(msg_list) { compose_fade.update_message_list(); - left_sidebar_navigation_area.handle_narrow_deactivated(); pm_list.handle_narrow_deactivated(); stream_list.handle_narrow_deactivated(); message_edit.handle_narrow_deactivated(); diff --git a/web/tests/left_sidebar_navigation_area.test.js b/web/tests/left_sidebar_navigation_area.test.js index 91e17636bb..8727e094d5 100644 --- a/web/tests/left_sidebar_navigation_area.test.js +++ b/web/tests/left_sidebar_navigation_area.test.js @@ -35,9 +35,9 @@ run_test("narrowing", () => { // deactivating narrow - left_sidebar_navigation_area.handle_narrow_deactivated(); + left_sidebar_navigation_area.handle_narrow_activated(new Filter()); - assert.ok($(".top_left_all_messages").hasClass("active-filter")); + assert.ok(!$(".top_left_all_messages").hasClass("active-filter")); 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")); @@ -53,7 +53,7 @@ run_test("narrowing", () => { assert.ok(!$(".top_left_inbox").hasClass("active-filter")); assert.ok($(".top_left_recent_view").hasClass("active-filter")); - left_sidebar_navigation_area.handle_narrow_deactivated(); + left_sidebar_navigation_area.handle_narrow_activated(new Filter()); left_sidebar_navigation_area.highlight_inbox_view(); assert.ok(!$(".top_left_all_messages").hasClass("active-filter")); assert.ok(!$(".top_left_mentions").hasClass("active-filter")); diff --git a/web/tests/narrow_activate.test.js b/web/tests/narrow_activate.test.js index 7e3d181c02..f7e49262be 100644 --- a/web/tests/narrow_activate.test.js +++ b/web/tests/narrow_activate.test.js @@ -194,8 +194,8 @@ run_test("basics", ({override}) => { [compose_closed_ui, "update_reply_recipient_label"], [message_view_header, "render_title_area"], [notifications, "redraw_title"], - [compose_actions, "on_narrow"], [left_sidebar_navigation_area, "handle_narrow_activated"], + [compose_actions, "on_narrow"], [stream_list, "handle_narrow_activated"], [compose_recipient, "update_narrow_to_recipient_visibility"], ]);