buddy_list: Set html instead of append for view all subscribers link.

Earlier, we were appending view all subscribers link using
JQuery.append, which leaves open the possibility for the component to
be appended multiple times if the function calling it gets called
multiple times.
It is better to have the link div in right_sidebar.hbs
and then insert the html when required.
This commit is contained in:
Shubham Padia
2025-06-05 08:08:01 +00:00
committed by Tim Abbott
parent 90a1f0f7aa
commit 7b925ce94a
4 changed files with 12 additions and 15 deletions

View File

@@ -366,7 +366,7 @@ export class BuddyList extends BuddyListConf {
this.fill_screen_with_content();
// This must happen after `fill_screen_with_content`
$("#buddy-list-users-matching-view-container .view-all-subscribers-link").remove();
$("#buddy-list-users-matching-view-container .view-all-subscribers-link").empty();
$("#buddy-list-other-users-container .view-all-users-link").empty();
void this.render_view_user_list_links();
this.display_or_hide_sections();
@@ -746,12 +746,10 @@ export class BuddyList extends BuddyListConf {
current_sub,
"subscribers",
);
$("#buddy-list-users-matching-view-container").append(
$(
render_view_all_subscribers({
stream_edit_hash,
}),
),
$("#buddy-list-users-matching-view-container .view-all-subscribers-link").html(
render_view_all_subscribers({
stream_edit_hash,
}),
);
}

View File

@@ -1,7 +1,5 @@
<div class="buddy-list-user-link view-all-subscribers-link">
<a class="right-sidebar-wrappable-text-container" href="{{stream_edit_hash}}">
<span class="right-sidebar-wrappable-text-inner">
{{t "View all subscribers" }}
</span>
</a>
</div>
<a class="right-sidebar-wrappable-text-container" href="{{stream_edit_hash}}">
<span class="right-sidebar-wrappable-text-inner">
{{t "View all subscribers" }}
</span>
</a>

View File

@@ -20,6 +20,7 @@
<div id="buddy-list-users-matching-view-container" class="buddy-list-section-container">
<div class="buddy-list-subsection-header"></div>
<ul id="buddy-list-users-matching-view" class="buddy-list-section"></ul>
<div class="buddy-list-user-link view-all-subscribers-link"></div>
</div>
<div id="buddy-list-other-users-container" class="buddy-list-section-container">
<div class="buddy-list-subsection-header"></div>

View File

@@ -41,7 +41,7 @@ exports.stub_buddy_list_elements = () => {
$("#buddy-list-users-matching-view .empty-list-message").length = 0;
$("#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-users-matching-view-container .view-all-subscribers-link").empty = 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;