stream settings: Hide subscribe/unsubscribe as needed.

For public stream, always show subscription option.
For private stream, if user is subscribed display unsubscribe option.
If user is not subscribe, do not display subscription option.
This commit is contained in:
YJDave 2018-01-04 09:17:51 +05:30 committed by Steve Howell
parent 690e82e624
commit 7ccaf2dc48
2 changed files with 5 additions and 0 deletions

View File

@ -170,6 +170,9 @@ exports.update_calculated_fields = function (sub) {
// stream is private and admin is subscribed to private stream.
sub.can_change_name_description = page_params.is_admin &&
(!sub.invite_only || (sub.invite_only && sub.subscribed));
// If stream is public then any user can subscribe. If stream is private then only
// subscribed users can unsubscribe.
sub.should_display_subscription_button = !sub.invite_only || sub.subscribed;
sub.can_make_public = page_params.is_admin && sub.invite_only && sub.subscribed;
sub.can_make_private = page_params.is_admin && !sub.invite_only;
sub.preview_url = narrow.by_stream_uri(sub.name);

View File

@ -18,8 +18,10 @@
{{/if}}
</div>
<div class="button-group">
{{#if should_display_subscription_button}}
<button class="button small rounded subscribe-button sub_unsub_button {{#unless subscribed }}unsubscribed{{/unless}}" type="button" name="button" title="{{t 'Toggle subscription'}} (S)">
{{#if subscribed }}{{#tr oneself }}Unsubscribe{{/tr}}{{else}}{{#tr oneself }}Subscribe{{/tr}}{{/if}}</button>
{{/if}}
<a href="{{preview_url}}" class="button small rounded" id="preview-stream-button" role="button" title="{{t 'View stream'}} (V)">{{t "View stream"}}</a>
</div>
</div>