Fix port selection

10.9-maintenance
ASDosjani 2022-09-01 21:43:12 +02:00
parent b5c2216970
commit 614eb5d957
2 changed files with 19 additions and 12 deletions

View File

@ -26,9 +26,6 @@ PortHandler.initialize = function () {
this.selectList = document.querySelector(portPickerElementSelector); this.selectList = document.querySelector(portPickerElementSelector);
this.initialWidth = this.selectList.offsetWidth + 12; this.initialWidth = this.selectList.offsetWidth + 12;
this.showVirtualMode = ConfigStorage.get('showVirtualMode').showVirtualMode;
this.showAllSerialDevices = ConfigStorage.get('showAllSerialDevices').showAllSerialDevices;
// fill dropdown with version numbers // fill dropdown with version numbers
generateVirtualApiVersions(); generateVirtualApiVersions();
@ -120,8 +117,17 @@ PortHandler.initialize = function () {
} }
}, MDNS_INTERVAL); }, MDNS_INTERVAL);
// start listening, check after TIMEOUT_CHECK ms this.reinitialize(); // just to prevent code redundancy
this.check(); };
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 () { PortHandler.check = function () {
@ -135,7 +141,7 @@ PortHandler.check = function () {
self.check_serial_devices(); self.check_serial_devices();
} }
setTimeout(function () { self.usbCheckLoop = setTimeout(function () {
self.check(); self.check();
}, TIMEOUT_CHECK); }, TIMEOUT_CHECK);
}; };
@ -196,7 +202,7 @@ PortHandler.check_usb_devices = function (callback) {
data: {isManual: true}, data: {isManual: true},
})); }));
self.portPickerElement.val('DFU').change(); self.portPickerElement.val('DFU').trigger('change');
self.setPortsInputWidth(); self.setPortsInputWidth();
} }
self.dfu_available = true; self.dfu_available = true;

View File

@ -133,8 +133,10 @@ options.initShowAllSerialDevices = function() {
const result = ConfigStorage.get('showAllSerialDevices'); const result = ConfigStorage.get('showAllSerialDevices');
showAllSerialDevicesElement showAllSerialDevicesElement
.prop('checked', !!result.showAllSerialDevices) .prop('checked', !!result.showAllSerialDevices)
.on('change', () => ConfigStorage.set({ showAllSerialDevices: showAllSerialDevicesElement.is(':checked') })) .on('change', () => {
.trigger('change'); ConfigStorage.set({ showAllSerialDevices: showAllSerialDevicesElement.is(':checked') });
PortHandler.reinitialize();
});
}; };
options.initShowVirtualMode = function() { options.initShowVirtualMode = function() {
@ -144,9 +146,8 @@ options.initShowVirtualMode = function() {
.prop('checked', !!result.showVirtualMode) .prop('checked', !!result.showVirtualMode)
.on('change', () => { .on('change', () => {
ConfigStorage.set({ showVirtualMode: showVirtualModeElement.is(':checked') }); ConfigStorage.set({ showVirtualMode: showVirtualModeElement.is(':checked') });
PortHandler.initialPorts = false; PortHandler.reinitialize();
}) });
.trigger('change');
}; };
options.initCordovaForceComputerUI = function () { options.initCordovaForceComputerUI = function () {