only check for new version on first include

This commit is contained in:
Ivan Socolsky 2014-09-10 15:39:36 -03:00
commit 0962271633

View file

@ -1,28 +1,33 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('VersionController', angular.module('copayApp.controllers').controller('VersionController',
function($scope, $rootScope, $http, notification) { function($scope, $rootScope, $http, notification) {
$scope.version = copay.version; $scope.version = copay.version;
$scope.commitHash = copay.commitHash; $scope.commitHash = copay.commitHash;
$scope.networkName = config.networkName; $scope.networkName = config.networkName;
$scope.defaultLanguage = config.defaultLanguage; $scope.defaultLanguage = config.defaultLanguage;
if (_.isUndefined($rootScope.checkVersion))
$rootScope.checkVersion = true;
$http.get('https://api.github.com/repos/bitpay/copay/tags').success(function(data) { if ($rootScope.checkVersion) {
var toInt = function(s) { $rootScope.checkVersion = false;
return parseInt(s); $http.get('https://api.github.com/repos/bitpay/copay/tags').success(function(data) {
}; var toInt = function(s) {
var latestVersion = data[0].name.replace('v', '').split('.').map(toInt); return parseInt(s);
var currentVersion = copay.version.split('.').map(toInt); };
var title = 'Copay ' + data[0].name + ' available.'; var latestVersion = data[0].name.replace('v', '').split('.').map(toInt);
var content; var currentVersion = copay.version.split('.').map(toInt);
if (currentVersion[0] < latestVersion[0]) { var title = 'Copay ' + data[0].name + ' available.';
content = 'It\'s important that you update your wallet at https://copay.io'; var content;
notification.version(title, content, true); if (currentVersion[0] < latestVersion[0]) {
} else if (currentVersion[0] == latestVersion[0] && currentVersion[1] < latestVersion[1]) { content = 'It\'s important that you update your wallet at https://copay.io';
var content = 'Please update your wallet at https://copay.io'; notification.version(title, content, true);
notification.version(title, content, false); } else if (currentVersion[0] == latestVersion[0] && currentVersion[1] < latestVersion[1]) {
} var content = 'Please update your wallet at https://copay.io';
}); notification.version(title, content, false);
}
});
}
}); });