diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js index 9e7817c731..e17760a40e 100644 --- a/static/js/stream_edit.js +++ b/static/js/stream_edit.js @@ -14,6 +14,14 @@ function settings_for_sub(sub) { return $("#subscription_overlay .subscription_settings[data-stream-id='" + id + "']"); } +exports.is_sub_settings_active = function (sub) { + var active_stream = subs.active_stream(); + if (active_stream !== undefined && active_stream.id === sub.stream_id) { + return true; + } + return false; +}; + function get_email_of_subscribers(subscribers) { var emails = []; subscribers.each(function (o, i) { diff --git a/static/js/subs.js b/static/js/subs.js index cfd7956296..d4e7253540 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -231,8 +231,7 @@ exports.update_settings_for_subscribed = function (sub) { exports.add_sub_to_table(sub); } - var active_stream = exports.active_stream(); - if (active_stream !== undefined && active_stream.id === sub.stream_id) { + if (stream_edit.is_sub_settings_active(sub)) { stream_edit.rerender_subscribers_list(sub); } @@ -251,9 +250,8 @@ exports.update_settings_for_unsubscribed = function (sub) { stream_edit.hide_sub_settings(sub); - var active_stream = exports.active_stream(); stream_data.update_stream_email_address(sub, ""); - if (active_stream !== undefined && active_stream.id === sub.stream_id) { + if (stream_edit.is_sub_settings_active(sub)) { stream_edit.rerender_subscribers_list(sub); // If user unsubscribed from private stream then user cannot subscribe to