diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js index d460ccce66..c59509e000 100644 --- a/static/js/stream_edit.js +++ b/static/js/stream_edit.js @@ -352,8 +352,11 @@ function change_stream_privacy(e) { sub.invite_only = invite_only; sub.is_announcement_only = is_announcement_only; sub.history_public_to_subscribers = history_public_to_subscribers; + stream_data.update_calculated_fields(sub); - stream_ui_updates.update_stream_privacy(sub); + stream_ui_updates.update_stream_privacy_type_icon(sub); + stream_ui_updates.update_stream_privacy_type_text(sub); + stream_list.redraw_stream_privacy(sub); $("#stream_privacy_modal").remove(); // For auto update, without rendering whole template diff --git a/static/js/stream_ui_updates.js b/static/js/stream_ui_updates.js index 294985c062..fc9d15aad0 100644 --- a/static/js/stream_ui_updates.js +++ b/static/js/stream_ui_updates.js @@ -70,30 +70,33 @@ exports.update_stream_row_in_settings_tab = function (sub) { } }; -exports.update_stream_privacy = function (sub) { +exports.update_stream_privacy_type_icon = function (sub) { var stream_settings = stream_edit.settings_for_sub(sub); var sub_row = subs.row_for_stream_id(sub.stream_id); - var html; + var html = templates.render('subscription_setting_icon', sub); - stream_data.update_calculated_fields(sub); - - html = templates.render('subscription_setting_icon', sub); - sub_row.find('.icon').expectOne().replaceWith($(html)); - - html = templates.render('subscription_type', sub); - stream_settings.find('.subscription-type-text').expectOne().html(html); - - if (sub.invite_only) { - stream_settings.find(".large-icon") - .removeClass("hash").addClass("lock") - .html(""); - } else { - stream_settings.find(".large-icon") - .addClass("hash").removeClass("lock") - .html(""); + if (overlays.streams_open()) { + sub_row.find('.icon').expectOne().replaceWith($(html)); } + if (stream_edit.is_sub_settings_active(sub)) { + var large_icon = stream_settings.find('.large-icon').expectOne(); + if (sub.invite_only) { + large_icon.removeClass("hash").addClass("lock") + .html(""); + } else { + large_icon.addClass("hash").removeClass("lock").html(""); + } + } +}; - stream_list.redraw_stream_privacy(sub); + + +exports.update_stream_privacy_type_text = function (sub) { + var stream_settings = stream_edit.settings_for_sub(sub); + var html = templates.render('subscription_type', sub); + if (stream_edit.is_sub_settings_active(sub)) { + stream_settings.find('.subscription-type-text').expectOne().html(html); + } }; return exports;