diff --git a/zephyr/static/js/subs.js b/zephyr/static/js/subs.js index abfff77019..fee76632a2 100644 --- a/zephyr/static/js/subs.js +++ b/zephyr/static/js/subs.js @@ -28,6 +28,10 @@ function should_render_subscribers() { return domain !== 'mit.edu'; } +function should_list_all_streams() { + return domain !== 'mit.edu'; +} + function update_table_stream_color(table, stream_name, color) { $.each(table.find(".stream_label"), function () { if ($(this).text() === stream_name) { @@ -207,6 +211,29 @@ exports.setup_page = function () { $('#streams').focus().select(); } + if (should_list_all_streams()) { + // This query must go first to prevent a race when we are not + // listing all streams + $.ajax({ + type: 'POST', + url: '/json/get_public_streams', + dataType: 'json', + timeout: 10*1000, + success: function (data) { + if (data) { + all_streams = data.streams; + maybe_populate_subscriptions(); + } + }, + error: function (xhr) { + util.destroy_loading_indicator($('#subs_page_loading_indicator')); + ui.report_error("Error listing subscriptions", xhr, $("#subscriptions-status")); + } + }); + } else { + all_streams = []; + } + $.ajax({ type: 'POST', url: '/json/subscriptions/list', @@ -223,23 +250,6 @@ exports.setup_page = function () { ui.report_error("Error listing subscriptions", xhr, $("#subscriptions-status")); } }); - - $.ajax({ - type: 'POST', - url: '/json/get_public_streams', - dataType: 'json', - timeout: 10*1000, - success: function (data) { - if (data) { - all_streams = data.streams; - 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) {