converse-desktop/app/controllers/default-controller.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-05-09 15:07:42 +00:00
let angApp = require(__dirname+'/../init')
2020-05-17 18:12:36 +00:00
angApp.controller('DefaultController', function($scope, $timeout, $http, AppInfo) {
$scope.appInfo = AppInfo
let getUpdateInfo = () => {
$http({
url: $scope.appInfo.APP_RELEASES_CHECK_URL,
method: 'GET'
}).then((response) => {
let releaseVersion = response.data[0].tag_name
if (releaseVersion == $scope.appInfo.APP_VERSION) {
$scope.checkingForUpdate = 'latest'
}
else {
$scope.checkingForUpdate = 'updateAvailable'
}
}, (error) => {
$scope.checkingForUpdate = 'checkErr'
})
}
let checkForUpdate = (timeout = 5000) => {
$scope.checkingForUpdate = 'inProgress'
$timeout(() => {
getUpdateInfo()
}, timeout)
}
let checkForUpdateDelayed = (timeout = 5000) => {
$timeout(() => {
checkForUpdate()
}, timeout)
}
checkForUpdateDelayed()
$scope.checkRetry = ($event) => {
$event.preventDefault()
checkForUpdate()
}
2020-05-13 20:01:42 +00:00
})