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)
This commit is contained in:
Keegan McAllister 2012-10-16 18:24:29 -04:00
parent 94f107e281
commit 91209f9304
4 changed files with 4 additions and 8 deletions

View File

@ -41,7 +41,6 @@
{# Not escaped, because it's guaranteed by the model to be an integer. #} {# Not escaped, because it's guaranteed by the model to be an integer. #}
var initial_pointer = {{ user_profile.pointer }}; var initial_pointer = {{ user_profile.pointer }};
var server_generation = {{ server_generation }};
var email = "{{ user_profile.user.email|escapejs }}"; var email = "{{ user_profile.user.email|escapejs }}";
var have_initial_messages = {{ have_initial_messages|escapejs }}; var have_initial_messages = {{ have_initial_messages|escapejs }};

View File

@ -7,7 +7,6 @@ var globals =
// index.html // index.html
+ ' initial_pointer email stream_list people_list have_initial_messages' + ' initial_pointer email stream_list people_list have_initial_messages'
+ ' server_generation'
// compose.js // compose.js
+ ' show_compose hide_compose toggle_compose clear_compose_box compose_button' + ' show_compose hide_compose toggle_compose clear_compose_box compose_button'

View File

@ -72,9 +72,6 @@ $(function () {
}); });
}); });
$(function () { get_updates_params.server_generation = server_generation; });
// The "message groups", i.e. blocks of messages collapsed by recipient. // The "message groups", i.e. blocks of messages collapsed by recipient.
// Each message table has a list of lists. // Each message table has a list of lists.
var message_groups = { var message_groups = {
@ -609,7 +606,9 @@ function get_updates() {
get_updates_params.failures = 0; get_updates_params.failures = 0;
$('#connection-error').hide(); $('#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; get_updates_params.reload_pending = true;
reload_app(); reload_app();
} }

View File

@ -192,8 +192,7 @@ def home(request):
'have_initial_messages': 'have_initial_messages':
'true' if num_messages > 0 else 'false', 'true' if num_messages > 0 else 'false',
'show_debug': 'show_debug':
settings.DEBUG and ('show_debug' in request.GET), settings.DEBUG and ('show_debug' in request.GET) },
'server_generation': SERVER_GENERATION},
context_instance=RequestContext(request)) context_instance=RequestContext(request))
@login_required_json_view @login_required_json_view