1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 08:45:28 +03:00

Flasher tab: remember last user selected radio protocol (#3475)

This commit is contained in:
Ivan Efimov 2023-06-15 11:16:36 -05:00 committed by GitHub
parent 5621658c97
commit e683231cce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,6 +66,10 @@ firmware_flasher.initialize = function (callback) {
);
}
function buildKeyExists() {
return FC.CONFIG.buildKey.length === 32;
}
function parseHex(str, callback) {
// parsing hex in different thread
const worker = new Worker('./js/workers/hex_parser.js');
@ -208,6 +212,19 @@ firmware_flasher.initialize = function (callback) {
buildOptionsList($('select[name="telemetryProtocols"]'), data.telemetryProtocols);
buildOptionsList($('select[name="options"]'), data.generalOptions);
buildOptionsList($('select[name="motorProtocols"]'), data.motorProtocols);
if (!buildKeyExists()) {
preselectRadioProtocolFromStorage();
}
}
function preselectRadioProtocolFromStorage() {
const storedRadioProtocol = getConfig("ffRadioProtocol").ffRadioProtocol;
if (storedRadioProtocol) {
const valueExistsInSelect = $('select[name="radioProtocols"] option').filter(function (i, o) {return o.value === storedRadioProtocol;}).length !== 0;
if (valueExistsInSelect) {
$('select[name="radioProtocols"]').val(storedRadioProtocol);
}
}
}
let buildTypesToShow;
@ -350,7 +367,7 @@ firmware_flasher.initialize = function (callback) {
self.releaseLoader.loadTarget(target, release, onTargetDetail);
if (FC.CONFIG.buildKey.length === 32 && navigator.onLine) {
if (buildKeyExists() && navigator.onLine) {
self.releaseLoader.loadOptionsByBuildKey(release, FC.CONFIG.buildKey, buildOptions);
} else {
self.releaseLoader.loadOptions(release, buildOptions);
@ -411,6 +428,13 @@ firmware_flasher.initialize = function (callback) {
$('select[name="options"]').select2({ closeOnSelect: false });
$('select[name="commits"]').select2({ tags: true });
$('select[name="radioProtocols"]').on("select2:select", function() {
const selectedProtocol = $('select[name="radioProtocols"] option:selected').first().val();
if (selectedProtocol) {
setConfig({"ffRadioProtocol" : selectedProtocol});
}
});
$('select[name="board"]').change(function() {
$("a.load_remote_file").addClass('disabled');
let target = $(this).val();
@ -607,7 +631,7 @@ firmware_flasher.initialize = function (callback) {
}
MSP.send_message(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.BUILD_KEY), false, () => {
if (FC.CONFIG.buildKey.length === 32) {
if (buildKeyExists()) {
self.releaseLoader.requestBuildOptions(FC.CONFIG.buildKey, onLoadCloudBuild, getBoardInfo);
} else {
getBoardInfo();