diff --git a/static/js/admin.js b/static/js/admin.js index f8567b3a4d..68e57644d0 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -153,8 +153,22 @@ exports.build_default_stream_table = function (streams_data) { loading.destroy_indicator($('#admin_page_default_streams_loading_indicator')); }()); + self.remove = function (stream_id) { + if (self.row_dict.has(stream_id)) { + var row = self.row_dict.get(stream_id); + row.remove(); + } + }; + return self; }; +var default_stream_table; + +exports.remove_default_stream = function (stream_id) { + if (default_stream_table) { + default_stream_table.remove(stream_id); + } +}; function get_non_default_streams_names(streams_data) { var non_default_streams_names = []; @@ -176,7 +190,7 @@ exports.update_default_streams_table = function () { if (/#*administration/.test(window.location.hash) || /#*settings/.test(window.location.hash)) { $("#admin_default_streams_table").expectOne().find("tr.default_stream_row").remove(); - exports.build_default_stream_table( + default_stream_table = exports.build_default_stream_table( page_params.realm_default_streams); } }; diff --git a/static/js/server_events.js b/static/js/server_events.js index 94f9b44f05..848866ceaa 100644 --- a/static/js/server_events.js +++ b/static/js/server_events.js @@ -157,6 +157,8 @@ function dispatch_normal_event(event) { } subs.remove_stream(stream.stream_id); stream_data.delete_sub(stream.stream_id); + admin.remove_default_stream(stream.stream_id); + stream_data.remove_default_stream(stream.stream_id); }); } break; diff --git a/static/js/stream_data.js b/static/js/stream_data.js index 21372b0d5a..fdf2f89065 100644 --- a/static/js/stream_data.js +++ b/static/js/stream_data.js @@ -394,6 +394,14 @@ exports.get_newbie_stream = function () { return undefined; }; +exports.remove_default_stream = function (stream_id) { + page_params.realm_default_streams = _.reject(page_params.realm_default_streams, + function (stream) { + return stream.stream_id === stream_id; + } + ); +}; + return exports; }());