refactor: Extract can_view_subscribers().

We also remove some needless uses of the calculated
field in the node tests.
This commit is contained in:
Steve Howell
2021-04-04 15:52:09 +00:00
committed by Tim Abbott
parent ea972569a3
commit 36fd76dc20
8 changed files with 10 additions and 15 deletions

View File

@@ -54,11 +54,10 @@ export function update_calculated_fields(sub) {
sub.should_display_subscription_button = stream_data.can_toggle_subscription(sub);
sub.should_display_preview_button = stream_data.can_preview(sub);
sub.can_change_stream_permissions = stream_data.can_change_permissions(sub);
// User can add other users to stream if stream is public or user is subscribed to stream.
// Guest users can't access subscribers of any(public or private) non-subscribed streams.
sub.can_access_subscribers =
page_params.is_admin || sub.subscribed || (!page_params.is_guest && !sub.invite_only);
sub.can_access_subscribers = stream_data.can_view_subscribers(sub);
sub.preview_url = hash_util.by_stream_uri(sub.stream_id);
// User can add other users to stream if stream is public or user is subscribed to stream.
sub.can_add_subscribers = !page_params.is_guest && (!sub.invite_only || sub.subscribed);
sub.is_old_stream = sub.stream_weekly_traffic !== null;
if (sub.rendered_description !== undefined) {