mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-24 16:55:24 +03:00
Add message for flashing not continuing after backup cancelled (#4393)
* Add message for flashing not continuing after backup cancelled * Use INVALID * Wait for port to be available again
This commit is contained in:
parent
0ea310fefe
commit
767edb8b3a
2 changed files with 31 additions and 7 deletions
|
@ -3765,6 +3765,9 @@
|
|||
"firmwareFlasherFailedToLoadUnifiedConfig": {
|
||||
"message": "Failed to load remote config for {{remote_file}}"
|
||||
},
|
||||
"firmwareFlasherCanceledBackup": {
|
||||
"message": "Backup cancelled, flashing aborted"
|
||||
},
|
||||
"firmwareFlasherLegacyLabel": {
|
||||
"message": "{{target}} (Legacy)",
|
||||
"description": "If we have a Unified target and a old style target available, we are labeling the older one"
|
||||
|
|
|
@ -1140,17 +1140,38 @@ firmware_flasher.initialize = function (callback) {
|
|||
function startBackup(callback) {
|
||||
// prevent connection while backup is in progress
|
||||
GUI.connect_lock = true;
|
||||
|
||||
const aborted = function (message) {
|
||||
GUI.connect_lock = false;
|
||||
self.isFlashing = false;
|
||||
self.enableFlashButton(true);
|
||||
self.enableLoadRemoteFileButton(true);
|
||||
self.enableLoadFileButton(true);
|
||||
GUI.interval_resume("sponsor");
|
||||
self.flashingMessage(i18n.getMessage(message), self.FLASH_MESSAGE_TYPES.INVALID);
|
||||
};
|
||||
|
||||
const callBackWhenPortAvailable = function () {
|
||||
const startTime = Date.now();
|
||||
const interval = setInterval(() => {
|
||||
if (PortHandler.portAvailable) {
|
||||
clearInterval(interval);
|
||||
callback();
|
||||
} else if (Date.now() - startTime > 5000) {
|
||||
clearInterval(interval);
|
||||
// failed to connect
|
||||
aborted("portsSelectNone");
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
|
||||
AutoBackup.execute((result) => {
|
||||
GUI.connect_lock = false;
|
||||
if (result) {
|
||||
callback();
|
||||
// wait for the port to be available again - timeout after 5 seconds
|
||||
callBackWhenPortAvailable();
|
||||
} else {
|
||||
self.isFlashing = false;
|
||||
self.enableFlashButton(true);
|
||||
self.enableLoadRemoteFileButton(true);
|
||||
self.enableLoadFileButton(true);
|
||||
GUI.interval_resume("sponsor");
|
||||
console.log(`${self.logHead} Backup failed, skipping flashing`);
|
||||
aborted("firmwareFlasherCanceledBackup");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue