mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-22 07:45:19 +03:00
Reworked version check to check for newer releases online
This commit is contained in:
parent
944154f42f
commit
c2710678a5
1 changed files with 32 additions and 7 deletions
39
main.js
39
main.js
|
@ -27,13 +27,32 @@ $(document).ready(function () {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check release time to inform people in case they are running old release
|
// check for newer releases online to inform people in case they are running an old release
|
||||||
if (CONFIGURATOR.releaseDate > (new Date().getTime() - (86400000 * 91))) { // 1 day = 86400000 miliseconds, * 91 = 3 month window
|
|
||||||
console.log('Application version is valid for another: ' + Math.round((CONFIGURATOR.releaseDate - (new Date().getTime() - (86400000 * 60))) / 86400000) + ' days');
|
chrome.storage.local.get(['lastVersionChecked', 'lastVersionAvailableOnline'], function(result) {
|
||||||
} else {
|
if (typeof result.lastVersionChecked === undefined || ($.now() - result.lastVersionChecked) > 3600*1000) {
|
||||||
console.log('Application version expired');
|
try {
|
||||||
GUI.log('You are using an old version of ' + chrome.runtime.getManifest().name + '. There may be a more recent version with improvements and fixes.');
|
var url = 'https://api.github.com/repos/betaflight/betaflight-configurator/tags';
|
||||||
}
|
$.get(url).done(function (data) {
|
||||||
|
var versions = data.sort(function (v1, v2) {
|
||||||
|
try {
|
||||||
|
return semver.compare(v2.name, v1.name);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
chrome.storage.local.set({'lastVersionChecked': $.now(), 'lastVersionAvailableOnline': versions[0].name}, function(result) {
|
||||||
|
console.log("Latest version available online: "+ versions[0].name);
|
||||||
|
});
|
||||||
|
notifyOutdatedVersion(versions[0].name);
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
// Just to catch and supress warnings if no internet connection is available
|
||||||
|
}
|
||||||
|
} else if (result.lastVersionAvailableOnline) {
|
||||||
|
notifyOutdatedVersion(result.lastVersionAvailableOnline);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
chrome.storage.local.get('logopen', function (result) {
|
chrome.storage.local.get('logopen', function (result) {
|
||||||
if (result.logopen) {
|
if (result.logopen) {
|
||||||
|
@ -318,6 +337,12 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function notifyOutdatedVersion (version) {
|
||||||
|
if (semver.lt(chrome.runtime.getManifest().version, version)) {
|
||||||
|
GUI.log('You are using an old version of ' + chrome.runtime.getManifest().name + '. Version ' + version + ' is available online with possible improvements and fixes.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function update_packet_error(caller) {
|
function update_packet_error(caller) {
|
||||||
$('span.packet-error').html(caller.packet_error);
|
$('span.packet-error').html(caller.packet_error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue