mirror of https://github.com/zulip/zulip.git
refactor: Extract stream_data.can_subscribe_others().
This commit is contained in:
parent
36fd76dc20
commit
430fadfb0b
|
@ -520,6 +520,11 @@ export function can_view_subscribers(sub) {
|
|||
return page_params.is_admin || sub.subscribed || (!page_params.is_guest && !sub.invite_only);
|
||||
}
|
||||
|
||||
export function can_subscribe_others(sub) {
|
||||
// User can add other users to stream if stream is public or user is subscribed to stream.
|
||||
return !page_params.is_guest && (!sub.invite_only || sub.subscribed);
|
||||
}
|
||||
|
||||
export function is_subscribed(stream_name) {
|
||||
const sub = get_sub(stream_name);
|
||||
return sub !== undefined && sub.subscribed;
|
||||
|
|
|
@ -55,11 +55,11 @@ export function update_calculated_fields(sub) {
|
|||
sub.should_display_preview_button = stream_data.can_preview(sub);
|
||||
sub.can_change_stream_permissions = stream_data.can_change_permissions(sub);
|
||||
sub.can_access_subscribers = stream_data.can_view_subscribers(sub);
|
||||
sub.can_add_subscribers = stream_data.can_subscribe_others(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) {
|
||||
sub.rendered_description = sub.rendered_description.replace("<p>", "").replace("</p>", "");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue