Don't try to show all streams on the subscriptions page for the MIT realm

The query fails anyway, so this is not a safety check.  This commit
makes it so that MIT users actually see their subscriptions instead
of an error.

(imported from commit ee635943728d7d9823e118d9fa51c402b1cd9bf2)
This commit is contained in:
Zev Benjamin 2013-01-23 11:51:01 -05:00
parent 3250e83e66
commit 6082222a68
1 changed files with 27 additions and 17 deletions

View File

@ -28,6 +28,10 @@ function should_render_subscribers() {
return domain !== 'mit.edu'; return domain !== 'mit.edu';
} }
function should_list_all_streams() {
return domain !== 'mit.edu';
}
function update_table_stream_color(table, stream_name, color) { function update_table_stream_color(table, stream_name, color) {
$.each(table.find(".stream_label"), function () { $.each(table.find(".stream_label"), function () {
if ($(this).text() === stream_name) { if ($(this).text() === stream_name) {
@ -207,23 +211,9 @@ exports.setup_page = function () {
$('#streams').focus().select(); $('#streams').focus().select();
} }
$.ajax({ if (should_list_all_streams()) {
type: 'POST', // This query must go first to prevent a race when we are not
url: '/json/subscriptions/list', // listing all streams
dataType: 'json',
timeout: 10*1000,
success: function (data) {
if (data) {
our_subs = data.subscriptions;
maybe_populate_subscriptions();
}
},
error: function (xhr) {
util.destroy_loading_indicator($('#subs_page_loading_indicator'));
ui.report_error("Error listing subscriptions", xhr, $("#subscriptions-status"));
}
});
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: '/json/get_public_streams', url: '/json/get_public_streams',
@ -240,6 +230,26 @@ exports.setup_page = function () {
ui.report_error("Error listing subscriptions", xhr, $("#subscriptions-status")); ui.report_error("Error listing subscriptions", xhr, $("#subscriptions-status"));
} }
}); });
} else {
all_streams = [];
}
$.ajax({
type: 'POST',
url: '/json/subscriptions/list',
dataType: 'json',
timeout: 10*1000,
success: function (data) {
if (data) {
our_subs = data.subscriptions;
maybe_populate_subscriptions();
}
},
error: function (xhr) {
util.destroy_loading_indicator($('#subs_page_loading_indicator'));
ui.report_error("Error listing subscriptions", xhr, $("#subscriptions-status"));
}
});
}; };
exports.subscribe_for_send = function (stream, prompt_button) { exports.subscribe_for_send = function (stream, prompt_button) {