From 211eba2c568f0f432b1f8589469291bf3cc1a9dd Mon Sep 17 00:00:00 2001 From: YJDave Date: Fri, 6 Apr 2018 10:18:46 +0530 Subject: [PATCH] stream_edit.js: Add helper func to check if sub settings tab is active. This commit adds a new helper func to check if sub settings tab is active or not and remove function `add_me_to_member_list` function from `static/js/stream_edit.js`, cause we don't need to render subscribers for particular case, as we are already doing that. --- static/js/stream_edit.js | 8 ++++++++ static/js/subs.js | 6 ++---- 2 files changed, 10 insertions(+), 4 deletions(-) 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