mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-13 11:29:53 +03:00
experimental storage of last used port in GUI
This commit is contained in:
parent
fa90fbcbc4
commit
2b4e5642b3
3 changed files with 27 additions and 1 deletions
|
@ -145,6 +145,18 @@ $(document).ready(function() {
|
|||
text: port
|
||||
}));
|
||||
});
|
||||
|
||||
chrome.storage.local.get('last_used_port', function(result) {
|
||||
// if last_used_port was set, we try to select it
|
||||
if (typeof result.last_used_port != 'undefined') {
|
||||
// check if same port exists, if it does, select it
|
||||
ports.forEach(function(port) {
|
||||
if (port == result.last_used_port) {
|
||||
$(port_picker).val(result.last_used_port);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$(port_picker).append($("<option/>", {
|
||||
value: 0,
|
||||
|
@ -218,6 +230,19 @@ function onOpen(openInfo) {
|
|||
if (connectionId != -1) {
|
||||
console.log('Connection was opened with ID: ' + connectionId);
|
||||
|
||||
// save selected port with chrome.storage if the port differs
|
||||
chrome.storage.local.get('last_used_port', function(result) {
|
||||
if (typeof result.last_used_port != 'undefined') {
|
||||
if (result.last_used_port != selected_port) {
|
||||
// last used port doesn't match the one found in local db, we will store the new one
|
||||
chrome.storage.local.set({'last_used_port': selected_port}, function() {
|
||||
// Debug message is currently disabled (we dont need to spam the console log with that)
|
||||
// console.log('Last selected port was saved in chrome.storage.');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
connection_delay = setTimeout(function() {
|
||||
// start polling
|
||||
serial_poll = setInterval(readPoll, 10);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue