From 91209f9304b1b573f7f4645081c437c997ead46d Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 16 Oct 2012 18:24:29 -0400 Subject: [PATCH] Get initial server generation from first get_updates result Embedding this in index.html won't work anymore, because the Django FastCGI and the Tornado servers might have been started at different times. (imported from commit 187909d0593449cf2989857671f9ca526723e451) --- templates/zephyr/index.html | 1 - tools/jslint/check-all.js | 1 - zephyr/static/js/zephyr.js | 7 +++---- zephyr/views.py | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/templates/zephyr/index.html b/templates/zephyr/index.html index 62c23cb8b7..520c5f64f9 100644 --- a/templates/zephyr/index.html +++ b/templates/zephyr/index.html @@ -41,7 +41,6 @@ {# Not escaped, because it's guaranteed by the model to be an integer. #} var initial_pointer = {{ user_profile.pointer }}; -var server_generation = {{ server_generation }}; var email = "{{ user_profile.user.email|escapejs }}"; var have_initial_messages = {{ have_initial_messages|escapejs }}; diff --git a/tools/jslint/check-all.js b/tools/jslint/check-all.js index b94846134b..5a2fef53ab 100644 --- a/tools/jslint/check-all.js +++ b/tools/jslint/check-all.js @@ -7,7 +7,6 @@ var globals = // index.html + ' initial_pointer email stream_list people_list have_initial_messages' - + ' server_generation' // compose.js + ' show_compose hide_compose toggle_compose clear_compose_box compose_button' diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 00d037b548..946e987d5d 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -72,9 +72,6 @@ $(function () { }); }); - -$(function () { get_updates_params.server_generation = server_generation; }); - // The "message groups", i.e. blocks of messages collapsed by recipient. // Each message table has a list of lists. var message_groups = { @@ -609,7 +606,9 @@ function get_updates() { get_updates_params.failures = 0; $('#connection-error').hide(); - if (data.server_generation !== get_updates_params.server_generation) { + if (get_updates_params.server_generation === -1) { + get_updates_params.server_generation = data.server_generation; + } else if (data.server_generation !== get_updates_params.server_generation) { get_updates_params.reload_pending = true; reload_app(); } diff --git a/zephyr/views.py b/zephyr/views.py index f9a0bce7b2..90b34e7ae4 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -192,8 +192,7 @@ def home(request): 'have_initial_messages': 'true' if num_messages > 0 else 'false', 'show_debug': - settings.DEBUG and ('show_debug' in request.GET), - 'server_generation': SERVER_GENERATION}, + settings.DEBUG and ('show_debug' in request.GET) }, context_instance=RequestContext(request)) @login_required_json_view