1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-15 12:25:15 +03:00

consider versions for unified targets

This commit is contained in:
Kyle K 2019-09-06 10:05:29 +00:00
parent 7bd1f16a52
commit f6934f234f

View file

@ -206,11 +206,27 @@ TABS.firmware_flasher.initialize = function (callback) {
loadUnifiedBuilds(releases); loadUnifiedBuilds(releases);
}; };
function checkOneVersionForUnification(version) {
return semver.gte(version.split(' ')[0], '4.1.0-RC1');
}
function checkBuildsForUnification(builds) {
// Find a build that is newer than 4.1.0, return true if found
let foundSuitable = false;
Object.keys(builds).forEach(function (key) {
builds[key].forEach(function(target) {
if (checkOneVersionForUnification(target.version)) {
foundSuitable = true;
}
});
});
return foundSuitable;
}
function loadUnifiedBuilds(builds) { function loadUnifiedBuilds(builds) {
var expirationPeriod = 3600 * 2; // Two of your earth hours. var expirationPeriod = 3600 * 2; // Two of your earth hours.
var checkTime = Math.floor(Date.now() / 1000); // Lets deal in seconds. var checkTime = Math.floor(Date.now() / 1000); // Lets deal in seconds.
// Come back to this, how to handle build type without unified targets? if (builds && checkBuildsForUnification(builds)) {
if (builds && builds["STM32F411"]) {
console.log('loaded some builds for later'); console.log('loaded some builds for later');
var storageTag = 'unifiedSourceCache'; var storageTag = 'unifiedSourceCache';
chrome.storage.local.get(storageTag, function (result) { chrome.storage.local.get(storageTag, function (result) {
@ -394,6 +410,9 @@ TABS.firmware_flasher.initialize = function (callback) {
if (targetVersions) { if (targetVersions) {
versions_element.append($("<option value='0'>{0} {1}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersionFor'), target))); versions_element.append($("<option value='0'>{0} {1}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersionFor'), target)));
targetVersions.forEach(function(descriptor) { targetVersions.forEach(function(descriptor) {
if (unifiedConfig && !checkOneVersionForUnification(descriptor.version)) {
return;
}
var select_e = var select_e =
$("<option value='{0}'>{0} - {1}</option>".format( $("<option value='{0}'>{0} - {1}</option>".format(
descriptor.version, descriptor.version,
@ -444,6 +463,7 @@ TABS.firmware_flasher.initialize = function (callback) {
chrome.storage.local.get(storageTag, function (result) { chrome.storage.local.get(storageTag, function (result) {
let storageObj = result[storageTag]; let storageObj = result[storageTag];
let bareBoard = null; let bareBoard = null;
// Check to see if the cached configuration is the one we want.
if (!storageObj || !storageObj.target || storageObj.target != target) { if (!storageObj || !storageObj.target || storageObj.target != target) {
// Have to go and try and get the unified config, and then do stuff // Have to go and try and get the unified config, and then do stuff
$.get(TABS.firmware_flasher.unifiedConfigs[target], function(data) { $.get(TABS.firmware_flasher.unifiedConfigs[target], function(data) {
@ -473,6 +493,11 @@ TABS.firmware_flasher.initialize = function (callback) {
isConfigLocal = false; isConfigLocal = false;
unifiedConfig = data; unifiedConfig = data;
bareBoard = data.split("\n")[0].split(' ')[3]; bareBoard = data.split("\n")[0].split(' ')[3];
if (bareBoard == target) {
// TODO test this, should skip a placeholder unified target
targetConfig = undefined;
unifiedConfig = undefined;
}
populateVersions(versions_e, TABS.firmware_flasher.releases[bareBoard],target); populateVersions(versions_e, TABS.firmware_flasher.releases[bareBoard],target);
} }
}); });