mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
stream_ui_updates: Extract update_subscribers_list function.
This commit is contained in:
committed by
Tim Abbott
parent
7d7cf3d786
commit
71e561de76
@@ -34,33 +34,13 @@ exports.is_sub_settings_active = function (sub) {
|
||||
return false;
|
||||
};
|
||||
|
||||
function get_email_of_subscribers(subscribers) {
|
||||
exports.get_email_of_subscribers = function (subscribers) {
|
||||
var emails = [];
|
||||
subscribers.each(function (o, i) {
|
||||
var email = people.get_person_from_user_id(i).email;
|
||||
emails.push(email);
|
||||
});
|
||||
return emails;
|
||||
}
|
||||
|
||||
exports.rerender_subscribers_list = function (sub) {
|
||||
if (!sub.can_access_subscribers) {
|
||||
$(".subscriber_list_settings_container").hide();
|
||||
} else {
|
||||
var emails = get_email_of_subscribers(sub.subscribers);
|
||||
var subscribers_list = list_render.get("stream_subscribers/" + sub.stream_id);
|
||||
|
||||
// Changing the data clears the rendered list and the list needs to be re-rendered.
|
||||
// Perform re-rendering only when the stream settings form of the corresponding
|
||||
// stream is open.
|
||||
if (subscribers_list) {
|
||||
exports.sort_but_pin_current_user_on_top(emails);
|
||||
subscribers_list.data(emails);
|
||||
subscribers_list.render();
|
||||
ui.update_scrollbar($(".subscriber_list_container"));
|
||||
}
|
||||
$(".subscriber_list_settings_container").show();
|
||||
}
|
||||
};
|
||||
|
||||
function clear_edit_panel() {
|
||||
@@ -188,7 +168,7 @@ function show_subscription_settings(sub_row) {
|
||||
var list = get_subscriber_list(sub_settings);
|
||||
list.empty();
|
||||
|
||||
var emails = get_email_of_subscribers(sub.subscribers);
|
||||
var emails = exports.get_email_of_subscribers(sub.subscribers);
|
||||
exports.sort_but_pin_current_user_on_top(emails);
|
||||
|
||||
list_render.create(list, emails, {
|
||||
|
||||
@@ -111,6 +111,31 @@ exports.update_subscribers_count = function (sub, just_subscribed) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.update_subscribers_list = function (sub) {
|
||||
// Render subscriptions only if stream settings is open
|
||||
if (!stream_edit.is_sub_settings_active(sub)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sub.can_access_subscribers) {
|
||||
$(".subscriber_list_settings_container").hide();
|
||||
} else {
|
||||
var emails = stream_edit.get_email_of_subscribers(sub.subscribers);
|
||||
var subscribers_list = list_render.get("stream_subscribers/" + sub.stream_id);
|
||||
|
||||
// Changing the data clears the rendered list and the list needs to be re-rendered.
|
||||
// Perform re-rendering only when the stream settings form of the corresponding
|
||||
// stream is open.
|
||||
if (subscribers_list) {
|
||||
stream_edit.sort_but_pin_current_user_on_top(emails);
|
||||
subscribers_list.data(emails);
|
||||
subscribers_list.render();
|
||||
ui.update_scrollbar($(".subscriber_list_container"));
|
||||
}
|
||||
$(".subscriber_list_settings_container").show();
|
||||
}
|
||||
};
|
||||
|
||||
return exports;
|
||||
}());
|
||||
|
||||
|
||||
@@ -171,10 +171,7 @@ exports.rerender_subscriptions_settings = function (sub) {
|
||||
}
|
||||
stream_data.update_subscribers_count(sub);
|
||||
stream_ui_updates.update_subscribers_count(sub);
|
||||
if (stream_edit.is_sub_settings_active(sub)) {
|
||||
// Render subscriptions only if stream settings is open
|
||||
stream_edit.rerender_subscribers_list(sub);
|
||||
}
|
||||
stream_ui_updates.update_subscribers_list(sub);
|
||||
};
|
||||
|
||||
function add_email_hint_handler() {
|
||||
@@ -267,9 +264,7 @@ exports.update_settings_for_subscribed = function (sub) {
|
||||
exports.add_sub_to_table(sub);
|
||||
}
|
||||
|
||||
if (stream_edit.is_sub_settings_active(sub)) {
|
||||
stream_edit.rerender_subscribers_list(sub);
|
||||
}
|
||||
stream_ui_updates.update_subscribers_list(sub);
|
||||
|
||||
// Display the swatch and subscription stream_settings
|
||||
stream_ui_updates.update_regular_sub_settings(sub);
|
||||
|
||||
Reference in New Issue
Block a user