stream settings: Update subscription count on subscription event.

On subscription add or removal event, render subscription count
template in case of user can't access subscribers.
This commit is contained in:
YJDave
2018-02-10 11:55:05 +05:30
committed by Tim Abbott
parent c5904499db
commit 3280135a4c
3 changed files with 14 additions and 7 deletions

View File

@@ -152,7 +152,13 @@ exports.set_color = function (stream_id, color) {
exports.rerender_subscribers_count = function (sub) {
var id = parseInt(sub.stream_id, 10);
stream_data.update_subscribers_count(sub);
$(".stream-row[data-stream-id='" + id + "'] .subscriber-count-text").text(sub.subscriber_count);
if (sub.can_add_subscribers) {
$(".stream-row[data-stream-id='" + id + "'] .subscriber-count-text").text(sub.subscriber_count);
} else {
var sub_count = templates.render("subscription_count", sub);
var stream_row = row_for_stream_id(sub.stream_id);
stream_row.find('.subscriber-count').expectOne().html(sub_count);
}
};
function add_email_hint(row, email_address_hint_content) {

View File

@@ -11,12 +11,7 @@
<div class="top-bar">
<div class="stream-name">{{name}}</div>
<div class="subscriber-count">
{{#if can_add_subscribers}}
<i class="icon-vector-user"></i>
<span class="subscriber-count-text">{{subscriber_count}}</span>
{{else}}
<i class="subscriber-count-lock icon-vector-lock"></i>
{{/if}}
{{partial "subscription_count"}}
</div>
</div>
<div class="description" data-no-description="{{t 'No description.'}}">{{{rendered_description}}}</div>

View File

@@ -0,0 +1,6 @@
{{#if can_add_subscribers}}
<i class="icon-vector-user"></i>
<span class="subscriber-count-text">{{subscriber_count}}</span>
{{else}}
<i class="subscriber-count-lock icon-vector-lock"></i>
{{/if}}