From 6082222a680adc3421dd9ecaf6824b6d3f17aa64 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Wed, 23 Jan 2013 11:51:01 -0500 Subject: [PATCH] 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) --- zephyr/static/js/subs.js | 44 ++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 17 deletions(-) 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) {