Index: gm/rebaseline_server/static/loader.js |
diff --git a/gm/rebaseline_server/static/loader.js b/gm/rebaseline_server/static/loader.js |
index 254d0fda05e1956ab39537fc7663bb443414c520..d82c2f74f0c96040ff34517c39b520c71cbdce0b 100644 |
--- a/gm/rebaseline_server/static/loader.js |
+++ b/gm/rebaseline_server/static/loader.js |
@@ -75,14 +75,20 @@ Loader.controller( |
function(data, status, header, config) { |
var dataHeader = data[constants.KEY__HEADER]; |
if (dataHeader[constants.KEY__HEADER__IS_STILL_LOADING]) { |
+ // Apply the server's requested reload delay to local time, |
+ // so we will wait the right number of seconds regardless of clock |
+ // skew between client and server. |
+ var reloadDelayInSeconds = |
+ dataHeader[constants.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE] - |
+ dataHeader[constants.KEY__HEADER__TIME_UPDATED]; |
+ var timeNow = new Date().getTime(); |
+ var timeToReload = timeNow + reloadDelayInSeconds * 1000; |
$scope.loadingMessage = |
"Server is still loading results; will retry at " + |
- $scope.localTimeString(dataHeader[ |
- constants.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE]); |
+ $scope.localTimeString(timeToReload / 1000); |
borenet
2014/03/10 17:51:14
Why not store this in a timeToReloadInSeconds vari
epoger
2014/03/10 18:04:47
The problem with that, is that I would need to div
|
$timeout( |
function(){location.reload();}, |
- (dataHeader[constants.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE] |
- * 1000) - new Date().getTime()); |
+ timeToReload - timeNow); |
} else { |
$scope.loadingMessage = "Processing data, please wait..."; |