Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
buddy_list: Fix bug where headers weren't being updated often enough.
evykassirer2367c4645511
diff --git a/web/src/buddy_list.ts b/web/src/buddy_list.tsindex d235be53cda..15c8ce6f641 100644--- a/web/src/buddy_list.ts+++ b/web/src/buddy_list.ts@@ -13,6 +13,7 @@ import * as blueslip from "./blueslip";import * as buddy_data from "./buddy_data";import type {BuddyUserInfo} from "./buddy_data";import {media_breakpoints_num} from "./css_variables";+import type {Filter} from "./filter";import * as hash_util from "./hash_util";import {$t} from "./i18n";import * as message_viewport from "./message_viewport";@@ -166,6 +167,7 @@ export class BuddyList extends BuddyListConf {$participants_list = $(this.participants_list_selector);$users_matching_view_list = $(this.matching_view_list_selector);$other_users_list = $(this.other_user_list_selector);+ current_filter: Filter | undefined;initialize_tooltips(): void {$("#right-sidebar").on(@@ -390,14 +392,20 @@ export class BuddyList extends BuddyListConf {render_section_headers(): void {const {hide_headers, participant_ids_set} = this.render_data;- // We only show the participants list if it has members, so updating even if we're updating- // the count, that can affect if we show/hide this section.+ // We only show the participants list if it has members, so even if we're not+ // changing filters and only updating user counts for the current filter, that+ // can affect if we show/hide this section.const show_participants_list = !hide_headers && participant_ids_set.size;$("#buddy-list-participants-container").toggleClass("no-display", !show_participants_list);- if ($(".buddy-list-subsection-header").children().length) {++ // If we're not changing filters, this just means some users were added or+ // removed but otherwise everything is the same, so we don't need to do a full+ // rerender.+ if (this.current_filter === narrow_state.filter()) {this.update_section_header_counts();return;}+ this.current_filter = narrow_state.filter();const {current_sub, total_human_subscribers_count, other_users_count, total_human_users} =this.render_data;diff --git a/web/tests/lib/buddy_list.js b/web/tests/lib/buddy_list.jsindex 492994587ee..a4c63195353 100644--- a/web/tests/lib/buddy_list.js+++ b/web/tests/lib/buddy_list.js@@ -44,5 +44,4 @@ exports.stub_buddy_list_elements = () => {$("#buddy-list-other-users-container .view-all-users-link").length = 0;$("#buddy-list-users-matching-view-container .view-all-subscribers-link").remove = noop;$("#buddy-list-other-users-container .view-all-users-link").remove = noop;- $(".buddy-list-subsection-header").children = () => [];};