Skip to content

Commit

Permalink
Merge pull request #2879 from haslinghuis/fix_expert_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
blckmn authored Apr 5, 2022
2 parents 7744058 + 2fb9308 commit 04b4c74
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,6 @@ function finishClose(finishedCallback) {
// reset active sensor indicators
sensor_status(0);

// reset expert mode
ConfigStorage.get('permanentExpertMode', function (result) {
const checked = result.permanentExpertMode;
$('input[name="expertModeCheckbox"]').prop('checked', checked).trigger('change');
});

if (wasConnected) {
// detach listeners and remove element data
$('#content').empty();
Expand Down Expand Up @@ -232,17 +226,22 @@ function onOpen(openInfo) {
GUI.log(i18n.getMessage('serialPortOpened', serial.connectionType === 'serial' ? [serial.connectionId] : [openInfo.socketId]));

// save selected port with chrome.storage if the port differs
ConfigStorage.get('last_used_port', function (result) {
if (result.last_used_port) {
if (result.last_used_port !== GUI.connected_to) {
// last used port doesn't match the one found in local db, we will store the new one
ConfigStorage.set({'last_used_port': GUI.connected_to});
}
} else {
// variable isn't stored yet, saving
let result = ConfigStorage.get('last_used_port');
if (result.last_used_port) {
if (result.last_used_port !== GUI.connected_to) {
// last used port doesn't match the one found in local db, we will store the new one
ConfigStorage.set({'last_used_port': GUI.connected_to});
}
});
} else {
// variable isn't stored yet, saving
ConfigStorage.set({'last_used_port': GUI.connected_to});
}

// reset expert mode
result = ConfigStorage.get('permanentExpertMode');
if (result.permanentExpertMode) {
$('input[name="expertModeCheckbox"]').prop('checked', result.permanentExpertMode).trigger('change');
}

serial.onReceive.addListener(read_serial);
setConnectionTimeout();
Expand Down

0 comments on commit 04b4c74

Please sign in to comment.