Skip to content

Commit

Permalink
Abort on dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Feb 11, 2024
1 parent ebc0b4f commit dfdbc4d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
3 changes: 0 additions & 3 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,6 @@
"firmwareVersionNotSupported": {
"message": "This firmware version is <span class=\"message-negative\">not supported</span>. Please upgrade to firmware that supports api version <strong>$1</strong> or higher. Use CLI for backup before flashing. CLI backup/restore procedure is in the documention.<br />Alternatively download and use an old version of the configurator if you are not ready to upgrade."
},
"firmwareVersionNotSupportedMax": {
"message": "This firmware version is <span class=\"message-negative\">not supported</span>. Please upgrade to a newer version of configurator. <br /><br /><a href=\"https://github.com/betaflight/betaflight-configurator/releases\" target=\"_blank\" rel=\"noopener noreferrer\">Download Betaflight Configurator</a>"
},
"firmwareTypeNotSupported": {
"message": "Non - Betaflight firmware is <span class=\"message-negative\">not supported</span>, except for CLI mode."
},
Expand Down
2 changes: 1 addition & 1 deletion src/js/data_storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const CONFIGURATOR = {
// all versions are specified and compared using semantic versioning http://semver.org/
API_VERSION_ACCEPTED: API_VERSION_1_41,
API_VERSION_MIN_SUPPORTED_BACKUP_RESTORE: API_VERSION_1_41,
API_VERSION_MAX_SUPPORTED: API_VERSION_1_46,
API_VERSION_MAX_SUPPORTED: API_VERSION_1_45,

connectionValid: false,
connectionValidCliOnly: false,
Expand Down
29 changes: 17 additions & 12 deletions src/js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,7 @@ function onOpen(openInfo) {
return;
}

const supported = semver.satisfies(FC.CONFIG.apiVersion, `${CONFIGURATOR.API_VERSION_ACCEPTED} - ${CONFIGURATOR.API_VERSION_MAX_SUPPORTED}`);

if (supported) {
if (semver.gte(FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_ACCEPTED)) {
MSP.send_message(MSPCodes.MSP_FC_VARIANT, false, false, function () {
if (FC.CONFIG.flightControllerIdentifier === 'BTFL') {
MSP.send_message(MSPCodes.MSP_FC_VERSION, false, false, function () {
Expand Down Expand Up @@ -378,11 +376,7 @@ function onOpen(openInfo) {

const dialog = $('.dialogConnectWarning')[0];

if (semver.lt(FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_ACCEPTED)) {
$('.dialogConnectWarning-content').html(i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.API_VERSION_ACCEPTED]));
} else {
$('.dialogConnectWarning-content').html(i18n.getMessage('firmwareVersionNotSupportedMax'));
}
$('.dialogConnectWarning-content').html(i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.API_VERSION_ACCEPTED]));

$('.dialogConnectWarning-closebtn').click(function() {
dialog.close();
Expand Down Expand Up @@ -493,18 +487,26 @@ function checkReportProblems() {
problemDialogList.empty();

let problems = [];
let abort = false;

if (semver.gt(FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MAX_SUPPORTED)) {
const problemName = 'API_VERSION_MAX_SUPPORTED';
problems.push({ name: problemName, description: i18n.getMessage(`reportProblemsDialog${problemName}`,
[CONFIGURATOR.latestVersion, CONFIGURATOR.latestVersionReleaseUrl, CONFIGURATOR.getDisplayVersion(), FC.CONFIG.flightControllerVersion])});
needsProblemReportingDialog = true;

abort = true;
GUI.timeout_remove('connecting'); // kill connecting timer
$('div.connect_controls a.connect').click(); // disconnect
}

needsProblemReportingDialog = checkReportProblem('MOTOR_PROTOCOL_DISABLED', problems) || needsProblemReportingDialog;
if (!abort) {
// only check for problems if we are not already aborting
needsProblemReportingDialog = checkReportProblem('MOTOR_PROTOCOL_DISABLED', problems) || needsProblemReportingDialog;

if (have_sensor(FC.CONFIG.activeSensors, 'acc')) {
needsProblemReportingDialog = checkReportProblem('ACC_NEEDS_CALIBRATION', problems) || needsProblemReportingDialog;
if (have_sensor(FC.CONFIG.activeSensors, 'acc')) {
needsProblemReportingDialog = checkReportProblem('ACC_NEEDS_CALIBRATION', problems) || needsProblemReportingDialog;
}
}

if (needsProblemReportingDialog) {
Expand All @@ -525,7 +527,10 @@ function checkReportProblems() {
$('#dialogReportProblems-closebtn').focus();
}

processUid();
if (!abort) {
// if we are not aborting, we can continue
processUid();
}
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/js/utils/checkForConfiguratorUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ function notifyOutdatedVersion(data) {
});

dialog.showModal();
} else {
CONFIGURATOR.latestVersion = data.version;
}
}

Expand Down

0 comments on commit dfdbc4d

Please sign in to comment.