Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
sidebar toggles: Lift code to display PM counts.
Steve Howellec80d2d5db7b
diff --git a/frontend_tests/node_tests/pm_list.js b/frontend_tests/node_tests/pm_list.jsindex 6b3d459e8dd..bd991c6f150 100644--- a/frontend_tests/node_tests/pm_list.js+++ b/frontend_tests/node_tests/pm_list.js@@ -10,7 +10,6 @@ mock_cjs("jquery", $);const narrow_state = mock_esm("../../static/js/narrow_state");const pm_list_dom = mock_esm("../../static/js/pm_list_dom");const unread = mock_esm("../../static/js/unread");-const unread_ui = mock_esm("../../static/js/unread_ui");const vdom = mock_esm("../../static/js/vdom", {render: () => "fake-dom-for-pm-list",});@@ -158,16 +157,9 @@ test("build_private_messages_list_bot", (override) => {test("update_dom_with_unread_counts", (override) => {let counts;- let toggle_button_set;- let expected_unread_count;override(narrow_state, "active", () => true);- override(unread_ui, "set_count_toggle_button", (elt, count) => {- toggle_button_set = true;- assert.equal(count, expected_unread_count);- });-const total_value = $.create("total-value-stub");const total_count = $.create("total-count-stub");const private_li = $(".top_left_private_messages");@@ -178,21 +170,17 @@ test("update_dom_with_unread_counts", (override) => {private_message_count: 10,};- expected_unread_count = 10;-- toggle_button_set = false;pm_list.update_dom_with_unread_counts(counts);- assert(toggle_button_set);+ assert.equal(total_value.text(), "10");+ assert(total_count.visible());counts = {private_message_count: 0,};- expected_unread_count = 0;-- toggle_button_set = false;pm_list.update_dom_with_unread_counts(counts);- assert(toggle_button_set);+ assert.equal(total_value.text(), "");+ assert(!total_count.visible());});test("get_active_user_ids_string", (override) => {diff --git a/static/js/pm_list.js b/static/js/pm_list.jsindex 5cc0754ae35..2c2a42420a4 100644--- a/static/js/pm_list.js+++ b/static/js/pm_list.js@@ -9,7 +9,6 @@ import * as pm_list_dom from "./pm_list_dom";import * as stream_popover from "./stream_popover";import * as ui from "./ui";import * as unread from "./unread";-import * as unread_ui from "./unread_ui";import * as vdom from "./vdom";let prior_dom;@@ -169,8 +168,4 @@ export function expand() {export function update_dom_with_unread_counts(counts) {update_private_messages();set_count(counts.private_message_count);- unread_ui.set_count_toggle_button(- $("#userlist-toggle-unreadcount"),- counts.private_message_count,- );}diff --git a/static/js/unread_ui.js b/static/js/unread_ui.jsindex ed127e81748..32d65935d6c 100644--- a/static/js/unread_ui.js+++ b/static/js/unread_ui.js@@ -60,7 +60,10 @@ export function update_unread_counts() {const notifiable_unread_count = unread.calculate_notifiable_count(res);notifications.update_unread_counts(notifiable_unread_count, res.private_message_count);+ // Set the unread counts that we show in the buttons that+ // toggle open the sidebar menus when we have a thin window.set_count_toggle_button($("#streamlist-toggle-unreadcount"), res.home_unread_messages);+ set_count_toggle_button($("#userlist-toggle-unreadcount"), res.private_message_count);}export function should_display_bankruptcy_banner() {