forked from iNavFlight/inav-configurator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappUpdater.js
43 lines (34 loc) · 1.28 KB
/
appUpdater.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
const semver = require('semver');
const { GUI } = require('./gui');
const jBox = require('./libraries/jBox/jBox.min');
const i18n = require('./localization');
var appUpdater = appUpdater || {};
appUpdater.checkRelease = function (currVersion) {
var modalStart;
$.get('https://api.github.com/repos/iNavFlight/inav-configurator/releases/latest', function (releaseData) {
GUI.log(i18n.getMessage('loadedReleaseInfo'));
let newVersion = releaseData.tag_name;
let newPrerelase = releaseData.prerelease;
if (newPrerelase == false && semver.gt(newVersion, currVersion)) {
GUI.log(newVersion, app.getVersion());
GUI.log(currVersion);
GUI.log(i18n.getMessage('newVersionAvailable'));
modalStart = new jBox('Modal', {
width: 400,
height: 200,
animation: false,
closeOnClick: false,
closeOnEsc: true,
content: $('#appUpdateNotification')
}).open();
}
});
$('#update-notification-close').on('click', function () {
modalStart.close();
});
$('#update-notification-download').on('click', function () {
modalStart.close();
});
};
module.exports = appUpdater;