Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/betaflight/betaflight-configurator.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorASDosjani <aronmartonffy@gmail.com>2022-09-01 22:43:12 +0300
committerASDosjani <aronmartonffy@gmail.com>2022-10-16 21:31:24 +0300
commit614eb5d9576037e52ed7d76d44335945cc2f7874 (patch)
tree86dbb5e1c504e17281519bfbb1792e0b62fc0fee
parentb5c2216970972a83a57e6239b8a9bf641997e021 (diff)
Fix port selection
-rw-r--r--src/js/port_handler.js20
-rw-r--r--src/js/tabs/options.js11
2 files changed, 19 insertions, 12 deletions
diff --git a/src/js/port_handler.js b/src/js/port_handler.js
index bf8508ba..bfa5d626 100644
--- a/src/js/port_handler.js
+++ b/src/js/port_handler.js
@@ -26,9 +26,6 @@ PortHandler.initialize = function () {
this.selectList = document.querySelector(portPickerElementSelector);
this.initialWidth = this.selectList.offsetWidth + 12;
- this.showVirtualMode = ConfigStorage.get('showVirtualMode').showVirtualMode;
- this.showAllSerialDevices = ConfigStorage.get('showAllSerialDevices').showAllSerialDevices;
-
// fill dropdown with version numbers
generateVirtualApiVersions();
@@ -120,8 +117,17 @@ PortHandler.initialize = function () {
}
}, MDNS_INTERVAL);
- // start listening, check after TIMEOUT_CHECK ms
- this.check();
+ this.reinitialize(); // just to prevent code redundancy
+};
+
+PortHandler.reinitialize = function () {
+ this.initialPorts = false;
+ if (this.usbCheckLoop) {
+ clearTimeout(this.usbCheckLoop);
+ }
+ this.showVirtualMode = ConfigStorage.get('showVirtualMode').showVirtualMode;
+ this.showAllSerialDevices = ConfigStorage.get('showAllSerialDevices').showAllSerialDevices;
+ this.check(); // start listening, check after TIMEOUT_CHECK ms
};
PortHandler.check = function () {
@@ -135,7 +141,7 @@ PortHandler.check = function () {
self.check_serial_devices();
}
- setTimeout(function () {
+ self.usbCheckLoop = setTimeout(function () {
self.check();
}, TIMEOUT_CHECK);
};
@@ -196,7 +202,7 @@ PortHandler.check_usb_devices = function (callback) {
data: {isManual: true},
}));
- self.portPickerElement.val('DFU').change();
+ self.portPickerElement.val('DFU').trigger('change');
self.setPortsInputWidth();
}
self.dfu_available = true;
diff --git a/src/js/tabs/options.js b/src/js/tabs/options.js
index 5f6b7535..b75d4c38 100644
--- a/src/js/tabs/options.js
+++ b/src/js/tabs/options.js
@@ -133,8 +133,10 @@ options.initShowAllSerialDevices = function() {
const result = ConfigStorage.get('showAllSerialDevices');
showAllSerialDevicesElement
.prop('checked', !!result.showAllSerialDevices)
- .on('change', () => ConfigStorage.set({ showAllSerialDevices: showAllSerialDevicesElement.is(':checked') }))
- .trigger('change');
+ .on('change', () => {
+ ConfigStorage.set({ showAllSerialDevices: showAllSerialDevicesElement.is(':checked') });
+ PortHandler.reinitialize();
+ });
};
options.initShowVirtualMode = function() {
@@ -144,9 +146,8 @@ options.initShowVirtualMode = function() {
.prop('checked', !!result.showVirtualMode)
.on('change', () => {
ConfigStorage.set({ showVirtualMode: showVirtualModeElement.is(':checked') });
- PortHandler.initialPorts = false;
- })
- .trigger('change');
+ PortHandler.reinitialize();
+ });
};
options.initCordovaForceComputerUI = function () {