create stream: Fix preview btn not showing on private stream creation.

Fixes #9028
This commit is contained in:
Yashashvi Dave 2018-04-30 18:33:23 +05:30 committed by Tim Abbott
parent 86eddd79bc
commit dbd24c5c93
3 changed files with 4 additions and 11 deletions

View File

@ -204,6 +204,8 @@ exports.update_calculated_fields = function (sub) {
// If stream is public then any user can subscribe. If stream is private then only // If stream is public then any user can subscribe. If stream is private then only
// subscribed users can unsubscribe. // subscribed users can unsubscribe.
sub.should_display_subscription_button = !sub.invite_only || sub.subscribed; sub.should_display_subscription_button = !sub.invite_only || sub.subscribed;
sub.should_display_preview_button = sub.subscribed || !sub.invite_only ||
sub.previously_subscribed;
sub.can_make_public = page_params.is_admin && 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.can_make_private = page_params.is_admin && !sub.invite_only;
sub.can_change_subscription_type = sub.can_make_public || sub.can_make_private; sub.can_change_subscription_type = sub.can_make_public || sub.can_make_private;

View File

@ -256,6 +256,7 @@ exports.update_settings_for_subscribed = function (sub) {
var button = check_button_for_sub(sub); var button = check_button_for_sub(sub);
var settings_button = settings_button_for_sub(sub).removeClass("unsubscribed").show(); var settings_button = settings_button_for_sub(sub).removeClass("unsubscribed").show();
$('.add_subscribers_container').show(); $('.add_subscribers_container').show();
$(".subscription_settings[data-stream-id='" + sub.stream_id + "'] #preview-stream-button").show();
if (button.length !== 0) { if (button.length !== 0) {
exports.rerender_subscribers_count(sub, true); exports.rerender_subscribers_count(sub, true);

View File

@ -23,17 +23,7 @@
{{/if}} {{/if}}
<button class="button small rounded subscribe-button sub_unsub_button {{#unless subscribed }}unsubscribed{{/unless}}" type="button" name="button" title="{{t 'Toggle subscription'}} (S)" {{#unless should_display_subscription_button}}style="display: none"{{/unless}}> <button class="button small rounded subscribe-button sub_unsub_button {{#unless subscribed }}unsubscribed{{/unless}}" type="button" name="button" title="{{t 'Toggle subscription'}} (S)" {{#unless should_display_subscription_button}}style="display: none"{{/unless}}>
{{#if subscribed }}{{#tr oneself }}Unsubscribe{{/tr}}{{else}}{{#tr oneself }}Subscribe{{/tr}}{{/if}}</button> {{#if subscribed }}{{#tr oneself }}Unsubscribe{{/tr}}{{else}}{{#tr oneself }}Subscribe{{/tr}}{{/if}}</button>
{{#if invite_only}} <a href="{{preview_url}}" class="button small rounded" id="preview-stream-button" role="button" title="{{t 'View stream'}} (V)" {{#unless should_display_preview_button }}style="display: none"{{/unless}}>{{t "View stream"}}</a>
{{#if subscribed}}
<a href="{{preview_url}}" class="button small rounded" id="preview-stream-button" role="button" title="{{t 'View stream'}} (V)">{{t "View stream"}}</a>
{{else}}
{{#if previously_subscribed}}
<a href="{{preview_url}}" class="button small rounded" id="preview-stream-button" role="button" title="{{t 'View stream'}} (V)">{{t "View stream"}}</a>
{{/if}}
{{/if}}
{{else}}
<a href="{{preview_url}}" class="button small rounded" id="preview-stream-button" role="button" title="{{t 'View stream'}} (V)">{{t "View stream"}}</a>
{{/if}}
</div> </div>
</div> </div>
<div class="stream-description"> <div class="stream-description">