Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
Revert "pm_list: Handle narrow functions separately for pm_section."
Anders Kaseorg1f9573d527b8
diff --git a/frontend_tests/node_tests/top_left_corner.js b/frontend_tests/node_tests/top_left_corner.jsindex 09e7042cb38..e6282fead6a 100644--- a/frontend_tests/node_tests/top_left_corner.js+++ b/frontend_tests/node_tests/top_left_corner.js@@ -30,7 +30,7 @@ run_test("narrowing", ({override}) => {assert.ok(!pm_expanded);let filter = new Filter([{operator: "is", operand: "private"}]);- pm_list.handle_narrow_activated(filter);+ top_left_corner.handle_narrow_activated(filter);assert.ok(pm_expanded);const alice = {@@ -49,23 +49,23 @@ run_test("narrowing", ({override}) => {pm_expanded = false;filter = new Filter([{operator: "pm-with", operand: "[email protected]"}]);- pm_list.handle_narrow_activated(filter);+ top_left_corner.handle_narrow_activated(filter);assert.ok(pm_expanded);pm_expanded = false;filter = new Filter([{operator: "pm-with", operand: "[email protected],[email protected]"}]);- pm_list.handle_narrow_activated(filter);+ top_left_corner.handle_narrow_activated(filter);assert.ok(pm_expanded);pm_expanded = false;filter = new Filter([{operator: "pm-with", operand: "[email protected]"}]);- pm_list.handle_narrow_activated(filter);+ top_left_corner.handle_narrow_activated(filter);assert.ok(!pm_expanded);pm_expanded = false;people.deactivate(alice);filter = new Filter([{operator: "pm-with", operand: "[email protected]"}]);- pm_list.handle_narrow_activated(filter);+ top_left_corner.handle_narrow_activated(filter);assert.ok(pm_expanded);filter = new Filter([{operator: "is", operand: "mentioned"}]);@@ -84,7 +84,6 @@ run_test("narrowing", ({override}) => {pm_closed = false;top_left_corner.handle_narrow_deactivated();- pm_list.handle_narrow_deactivated();assert.ok($(".top_left_all_messages").hasClass("active-filter"));assert.ok(!$(".top_left_mentions").hasClass("active-filter"));diff --git a/static/js/narrow.js b/static/js/narrow.jsindex 9e956022c92..f05409311ff 100644--- a/static/js/narrow.js+++ b/static/js/narrow.js@@ -25,7 +25,6 @@ import * as narrow_state from "./narrow_state";import * as notifications from "./notifications";import {page_params} from "./page_params";import * as people from "./people";-import * as pm_list from "./pm_list";import * as recent_topics_ui from "./recent_topics_ui";import * as recent_topics_util from "./recent_topics_util";import * as resize from "./resize";@@ -571,7 +570,6 @@ export function activate(raw_operators, opts) {const current_filter = narrow_state.filter();top_left_corner.handle_narrow_activated(current_filter);- pm_list.handle_narrow_activated(current_filter);stream_list.handle_narrow_activated(current_filter);typing_events.render_notifications_for_narrow();message_view_header.initialize();@@ -982,7 +980,6 @@ function handle_post_narrow_deactivate_processes() {}top_left_corner.handle_narrow_deactivated();- pm_list.handle_narrow_deactivated();stream_list.handle_narrow_deactivated();compose_closed_ui.update_buttons_for_stream();message_edit.handle_narrow_deactivated();diff --git a/static/js/pm_list.js b/static/js/pm_list.jsindex 7eb6ce49420..038cefce485 100644--- a/static/js/pm_list.js+++ b/static/js/pm_list.js@@ -1,7 +1,6 @@import $ from "jquery";import * as narrow_state from "./narrow_state";-import * as people from "./people";import * as pm_list_data from "./pm_list_data";import * as pm_list_dom from "./pm_list_dom";import * as stream_popover from "./stream_popover";@@ -75,36 +74,3 @@ export function update_dom_with_unread_counts(counts) {update_private_messages();set_count(counts.private_message_count);}--function should_expand_pm_list(filter) {- const op_is = filter.operands("is");-- if (op_is.length >= 1 && op_is.includes("private")) {- return true;- }-- const op_pm = filter.operands("pm-with");-- if (op_pm.length !== 1) {- return false;- }-- const emails_strings = op_pm[0];- const emails = emails_strings.split(",");-- const has_valid_emails = people.is_valid_bulk_emails_for_compose(emails);-- return has_valid_emails;-}--export function handle_narrow_activated(filter) {- if (should_expand_pm_list(filter)) {- expand();- } else {- close();- }-}--export function handle_narrow_deactivated() {- close();-}diff --git a/static/js/top_left_corner.js b/static/js/top_left_corner.jsindex fa4731ff49b..d9504665268 100644--- a/static/js/top_left_corner.js+++ b/static/js/top_left_corner.js@@ -1,5 +1,6 @@import $ from "jquery";+import * as people from "./people";import * as pm_list from "./pm_list";import * as resize from "./resize";import * as ui_util from "./ui_util";@@ -35,6 +36,27 @@ function deselect_top_left_corner_items() {remove($(".top_left_recent_topics"));}+function should_expand_pm_list(filter) {+ const op_is = filter.operands("is");++ if (op_is.length >= 1 && op_is.includes("private")) {+ return true;+ }++ const op_pm = filter.operands("pm-with");++ if (op_pm.length !== 1) {+ return false;+ }++ const emails_strings = op_pm[0];+ const emails = emails_strings.split(",");++ const has_valid_emails = people.is_valid_bulk_emails_for_compose(emails);++ return has_valid_emails;+}+export function handle_narrow_activated(filter) {deselect_top_left_corner_items();@@ -62,10 +84,17 @@ export function handle_narrow_activated(filter) {$filter_li.addClass("active-filter");}}++ if (should_expand_pm_list(filter)) {+ pm_list.expand();+ } else {+ pm_list.close();+ }}export function handle_narrow_deactivated() {deselect_top_left_corner_items();+ pm_list.close();const $filter_li = $(".top_left_all_messages");$filter_li.addClass("active-filter");