UI, history: update using xhr date header

Makes the 'updated since' contents query based on any previous update's
ajax Date response header instead of the client time. This may offer
more protection against incorrect client time.

This works (and may work better than the previous method) because the
Date header is floored and not rounded and seems to mark a time before
the contents query is made.

Resolves #2242 (hopefully)
This commit is contained in:
carlfeberhard
2016-05-10 09:35:25 -04:00
parent 3422b46fb4
commit 3672eda0ea
6 changed files with 15 additions and 10 deletions
@@ -172,10 +172,16 @@ var History = Backbone.Model
var self = this;
var lastUpdateTime = self.lastUpdateTime;
self.lastUpdateTime = new Date();
// note if there was no previous update time, all summary contents will be fetched
// note: if there was no previous update time, all summary contents will be fetched
return self.contents.fetchUpdated( lastUpdateTime )
.done( _.bind( self.checkForUpdates, self ) );
.done( function( response, status, xhr ){
var serverResponseDatetime;
try {
serverResponseDatetime = new Date( xhr.getResponseHeader( 'Date' ) );
} catch( err ){}
self.lastUpdateTime = serverResponseDatetime || new Date();
self.checkForUpdates( options );
});
},
/** */
@@ -208,7 +214,6 @@ var History = Backbone.Model
} else {
// otherwise, let listeners know that all updates have stopped
self.trigger( 'ready' );
// self.lastUpdateTime = null;
}
});
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long