From ed70a92ed3be00813ff8aff17ed39249d1d96ffe Mon Sep 17 00:00:00 2001 From: YJDave Date: Sun, 8 Apr 2018 10:36:42 +0530 Subject: [PATCH] subscription: Fix error in being re-subscribed to private stream. Fixes #9023 --- static/js/stream_edit.js | 3 +++ static/js/subs.js | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js index e17760a40e..75b3e222c3 100644 --- a/static/js/stream_edit.js +++ b/static/js/stream_edit.js @@ -58,6 +58,9 @@ exports.hide_sub_settings = function (sub) { }; exports.show_sub_settings = function (sub) { + if (!exports.is_sub_settings_active(sub)) { + return; + } var $settings = $(".subscription_settings[data-stream-id='" + sub.stream_id + "']"); if ($settings.find(".email-address").val().length === 0) { // Rerender stream email address, if not. diff --git a/static/js/subs.js b/static/js/subs.js index 56ff225c32..a98e9f1c88 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -203,6 +203,10 @@ function add_email_hint_handler() { } exports.add_sub_to_table = function (sub) { + if (exports.is_sub_already_present(sub)) { + return; + } + var html = templates.render('subscription', sub); var settings_html = templates.render('subscription_settings', sub); if (stream_create.get_name() === sub.name) { @@ -224,6 +228,14 @@ exports.add_sub_to_table = function (sub) { } }; +exports.is_sub_already_present = function (sub) { + var button = button_for_sub(sub); + if (button.length !== 0) { + return true; + } + return false; +}; + exports.remove_stream = function (stream_id) { // It is possible that row is empty when we deactivate a // stream, but we let jQuery silently handle that.