Live-update default streams when deleting streams.

When an admin deactivate a stream, we now remove the
appropriate row from the default streams tables for other
folks viewing default streams in the admin tables.
This commit is contained in:
Steve Howell 2017-02-18 11:38:19 -08:00 committed by Tim Abbott
parent 6af83e31f6
commit f28158d301
3 changed files with 25 additions and 1 deletions

View File

@ -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);
}
};

View File

@ -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;

View File

@ -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;
}());