mirror of https://github.com/zulip/zulip.git
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:
parent
6af83e31f6
commit
f28158d301
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
}());
|
||||
|
|
Loading…
Reference in New Issue