From 90a1f0f7aa2b0835c32ff2dcc5bae8a720c8c45a Mon Sep 17 00:00:00 2001 From: Shubham Padia Date: Thu, 5 Jun 2025 07:42:08 +0000 Subject: [PATCH] buddy_list: Set html instead of append for view all users link. Fixes https://chat.zulip.org/#narrow/channel/9-issues/topic/buddy.20list.20view.20all.20users.20appears.20twice Earlier, we were appending view all users link using JQuery.append, so when `render_view_user_list_links` is called twice, `view all users` appears twice. It is better to have the link div in right_sidebar.hbs and then insert the html when required. --- web/src/buddy_list.ts | 6 ++++-- web/templates/buddy_list/view_all_users.hbs | 12 +++++------- web/templates/right_sidebar.hbs | 1 + web/tests/lib/buddy_list.cjs | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/web/src/buddy_list.ts b/web/src/buddy_list.ts index 040e3a3918..1b76cda59c 100644 --- a/web/src/buddy_list.ts +++ b/web/src/buddy_list.ts @@ -367,7 +367,7 @@ export class BuddyList extends BuddyListConf { // This must happen after `fill_screen_with_content` $("#buddy-list-users-matching-view-container .view-all-subscribers-link").remove(); - $("#buddy-list-other-users-container .view-all-users-link").remove(); + $("#buddy-list-other-users-container .view-all-users-link").empty(); void this.render_view_user_list_links(); this.display_or_hide_sections(); void this.update_empty_list_placeholders(); @@ -758,7 +758,9 @@ export class BuddyList extends BuddyListConf { // We give a link to view the list of all users to help reduce confusion about // there being hidden (inactive) "other" users. if (has_inactive_other_users) { - $("#buddy-list-other-users-container").append($(render_view_all_users())); + $("#buddy-list-other-users-container .view-all-users-link").html( + render_view_all_users(), + ); } // Note that we don't show a link for the participants list because we expect diff --git a/web/templates/buddy_list/view_all_users.hbs b/web/templates/buddy_list/view_all_users.hbs index 43ca6296b4..67c3a82bef 100644 --- a/web/templates/buddy_list/view_all_users.hbs +++ b/web/templates/buddy_list/view_all_users.hbs @@ -1,7 +1,5 @@ - + + + {{t "View all users" }} + + diff --git a/web/templates/right_sidebar.hbs b/web/templates/right_sidebar.hbs index f0f0e4e254..0e6053ad7b 100644 --- a/web/templates/right_sidebar.hbs +++ b/web/templates/right_sidebar.hbs @@ -24,6 +24,7 @@
+
diff --git a/web/tests/lib/buddy_list.cjs b/web/tests/lib/buddy_list.cjs index 2f4763a9dd..a0c5e21199 100644 --- a/web/tests/lib/buddy_list.cjs +++ b/web/tests/lib/buddy_list.cjs @@ -42,7 +42,7 @@ exports.stub_buddy_list_elements = () => { $("#buddy-list-other-users .empty-list-message").length = 0; $("#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-other-users-container .view-all-users-link").empty = noop; $(`#buddy-list-users-matching-view .empty-list-message`).remove = noop; $(`#buddy-list-other-users .empty-list-message`).remove = noop; $(`#buddy-list-participants .empty-list-message`).remove = noop;