refactor latestReleaseService to new format

This commit is contained in:
Sebastiaan Pasma 2018-09-06 13:16:32 +02:00
commit 828cb927dc
No known key found for this signature in database
GPG key ID: 9A2B0C8B95A1D26F

View file

@ -1,10 +1,23 @@
'use strict';
angular.module('copayApp.services')
.factory('latestReleaseService', function latestReleaseServiceFactory($log, $http, $ionicPopup, configService, externalLinkService, gettextCatalog, platformInfo) {
var root = {};
(function() {
root.checkLatestRelease = function(cb) {
angular
.module('bitcoincom.services')
.factory('latestReleaseService', latestReleaseService);
function latestReleaseService($log, $http, $ionicPopup, configService, externalLinkService, gettextCatalog, platformInfo) {
var service = {
// Functions
checkLatestRelease: checkLatestRelease,
requestLatestRelease: requestLatestRelease,
showUpdatePopup: showUpdatePopup
};
return service;
function checkLatestRelease(cb) {
var releaseURL = configService.getDefaults().release.url;
requestLatestRelease(releaseURL, function (err, releaseData) {
@ -45,7 +58,6 @@ angular.module('copayApp.services')
$log.debug('A new version is available: ' + latestVersion);
//
var releaseNotes = false;
if (releaseData.body) {
var releaseLines = releaseData.body.split('\n');
@ -82,7 +94,7 @@ angular.module('copayApp.services')
label: label /* XX SP: Maybe we can use this in a later stage (with for example 1.0.0-rc2 the value will be "rc2" and false if there is no label) */
};
}
};
}
function requestLatestRelease(releaseURL, cb) {
$log.debug('Retrieving latest release information...');
@ -101,7 +113,7 @@ angular.module('copayApp.services')
});
}
root.showUpdatePopup = function () {
function showUpdatePopup() {
var buttons = [];
if (!platformInfo.isIOS) { // There is no GitHub-release for iPhone
@ -163,7 +175,6 @@ angular.module('copayApp.services')
buttons: buttons
});
}
};
return root;
});
}
}
})();