Better version change detection (fixes #808, fixes #810)

This commit is contained in:
Audrius Butkevicius 2014-10-06 23:42:13 +01:00
parent d3a9b126a6
commit e50469d84e
2 changed files with 22 additions and 12 deletions

View File

@ -20,10 +20,24 @@
var syncthing = angular.module('syncthing', ['pascalprecht.translate']);
var urlbase = 'rest';
var guiVersion = null;
syncthing.config(function ($httpProvider, $translateProvider) {
$httpProvider.defaults.xsrfHeaderName = 'X-CSRF-Token';
$httpProvider.defaults.xsrfCookieName = 'CSRF-Token';
$httpProvider.interceptors.push(function() {
return {
response: function(response) {
var responseVersion = response.headers()['x-syncthing-version'];
if (!guiVersion) {
guiVersion = responseVersion;
} else if (guiVersion != responseVersion) {
document.location.reload(true);
}
return response;
}
};
});
$translateProvider.useStaticFilesLoader({
prefix: 'lang/lang-',
@ -164,17 +178,13 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
return;
}
if (restarting) {
document.location.reload(true);
} else {
console.log('UIOnline');
$scope.init();
online = true;
restarting = false;
$('#networkError').modal('hide');
$('#restarting').modal('hide');
$('#shutdown').modal('hide');
}
console.log('UIOnline');
$scope.init();
online = true;
restarting = false;
$('#networkError').modal('hide');
$('#restarting').modal('hide');
$('#shutdown').modal('hide');
});
$scope.$on('UIOffline', function (event, arg) {

File diff suppressed because one or more lines are too long