stream_ui_updates: Extract `update_change_stream_privacy_settings`.

This commit is contained in:
Yashashvi Dave 2019-04-02 22:13:02 +05:30 committed by Tim Abbott
parent ecc165b899
commit 7a168216ff
3 changed files with 13 additions and 9 deletions

View File

@ -384,9 +384,7 @@ function change_stream_privacy(e) {
// For auto update, without rendering whole template // For auto update, without rendering whole template
stream_data.update_calculated_fields(sub); stream_data.update_calculated_fields(sub);
if (!sub.can_change_stream_permissions) { stream_ui_updates.update_change_stream_privacy_settings(sub);
$(".change-stream-privacy").hide();
}
}, },
error: function () { error: function () {
$("#change-stream-privacy-button").text(i18n.t("Try again")); $("#change-stream-privacy-button").text(i18n.t("Try again"));

View File

@ -44,6 +44,16 @@ exports.update_regular_sub_settings = function (sub) {
} }
}; };
exports.update_change_stream_privacy_settings = function (sub) {
var stream_privacy_btn = $(".change-stream-privacy");
if (sub.can_change_stream_permissions) {
stream_privacy_btn.show();
} else {
stream_privacy_btn.hide();
}
};
return exports; return exports;
}()); }());

View File

@ -266,10 +266,8 @@ exports.update_settings_for_subscribed = function (sub) {
exports.rerender_subscribers_count(sub, true); exports.rerender_subscribers_count(sub, true);
stream_ui_updates.update_check_button_for_sub(sub); stream_ui_updates.update_check_button_for_sub(sub);
stream_ui_updates.update_settings_button_for_sub(sub); stream_ui_updates.update_settings_button_for_sub(sub);
stream_ui_updates.update_change_stream_privacy_settings(sub);
if (sub.can_change_stream_permissions) {
$(".change-stream-privacy").show();
}
} else { } else {
exports.add_sub_to_table(sub); exports.add_sub_to_table(sub);
} }
@ -348,9 +346,7 @@ exports.update_settings_for_unsubscribed = function (sub) {
stream_ui_updates.update_check_button_for_sub(sub); stream_ui_updates.update_check_button_for_sub(sub);
stream_ui_updates.update_settings_button_for_sub(sub); stream_ui_updates.update_settings_button_for_sub(sub);
stream_ui_updates.update_regular_sub_settings(sub); stream_ui_updates.update_regular_sub_settings(sub);
if (!sub.can_change_stream_permissions) { stream_ui_updates.update_change_stream_privacy_settings(sub);
$(".change-stream-privacy").hide();
}
stream_data.update_stream_email_address(sub, ""); stream_data.update_stream_email_address(sub, "");
if (stream_edit.is_sub_settings_active(sub)) { if (stream_edit.is_sub_settings_active(sub)) {