stream-settings: Live update subscribers list correctly.

This commit fixes the live update of subscribers list
on changing can_remove_subscribers_group setting.

Previously, whole members panel, including the pill container
to add subscriebrs, is re-rendered. But the click and input
handlers for the add subscribers UI is not added again after
re-rendering and thus they do not work.

This commit updates the code to just re-render the subscribers
list which is only needed to update the "Unsubscribe" button.
This commit is contained in:
Sahil Batra 2024-08-22 12:07:13 +05:30 committed by Tim Abbott
parent 27bf68637b
commit 03ec0e1f14
3 changed files with 17 additions and 18 deletions

View File

@ -5,7 +5,7 @@ import {z} from "zod";
import render_unsubscribe_private_stream_modal from "../templates/confirm_dialog/confirm_unsubscribe_private_stream.hbs";
import render_inline_decorated_stream_name from "../templates/inline_decorated_stream_name.hbs";
import render_stream_member_list_entry from "../templates/stream_settings/stream_member_list_entry.hbs";
import render_stream_members from "../templates/stream_settings/stream_members.hbs";
import render_stream_members_table from "../templates/stream_settings/stream_members_table.hbs";
import render_stream_subscription_request_result from "../templates/stream_settings/stream_subscription_request_result.hbs";
import * as add_subscribers_pill from "./add_subscribers_pill";
@ -440,11 +440,9 @@ export function rerender_subscribers_list(sub: sub_store.StreamSubscription): vo
.get_edit_container(sub)
.find(".edit_subscribers_for_stream");
$parent_container.html(
render_stream_members({
can_access_subscribers: true,
$parent_container.find(".subscriber-list-box").html(
render_stream_members_table({
can_remove_subscribers: user_can_remove_subscribers,
render_subscribers: sub.render_subscribers,
}),
);
subscribers_list_widget = make_list_widget({

View File

@ -17,19 +17,7 @@
</span>
</div>
<div class="subscriber-list-box">
<div class="subscriber_list_container" data-simplebar data-simplebar-tab-index="-1">
<div class="subscriber_list_loading_indicator"></div>
<table id="stream_members_list" class="subscriber-list table table-striped">
<thead class="table-sticky-headers">
<th data-sort="alphabetic" data-sort-prop="full_name">{{t "Name" }}</th>
<th class="settings-email-column" data-sort="email">{{t "Email" }}</th>
{{#if can_remove_subscribers}}
<th>{{t "Actions" }}</th>
{{/if}}
</thead>
<tbody class="subscriber_table" data-empty="{{t 'This channel has no subscribers.' }}" data-search-results-empty="{{t 'No channel subscribers match your current filter.'}}"></tbody>
</table>
</div>
{{> stream_members_table}}
</div>
</div>
{{/render_subscribers}}

View File

@ -0,0 +1,13 @@
<div class="subscriber_list_container" data-simplebar data-simplebar-tab-index="-1">
<div class="subscriber_list_loading_indicator"></div>
<table id="stream_members_list" class="subscriber-list table table-striped">
<thead class="table-sticky-headers">
<th data-sort="alphabetic" data-sort-prop="full_name">{{t "Name" }}</th>
<th class="settings-email-column" data-sort="email">{{t "Email" }}</th>
{{#if can_remove_subscribers}}
<th>{{t "Actions" }}</th>
{{/if}}
</thead>
<tbody class="subscriber_table" data-empty="{{t 'This channel has no subscribers.' }}" data-search-results-empty="{{t 'No channel subscribers match your current filter.'}}"></tbody>
</table>
</div>