Skip to content

Commit

Permalink
Set erase_chip as default option when not set before
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Dec 29, 2023
1 parent 6577697 commit b67ffa2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/js/ConfigStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @param {string | string[]} key string or array of strings
* @returns {object}
*/
export function get(key) {
export function get(key, defaultValue = null) {
let result = {};
if (Array.isArray(key)) {
key.forEach(function (element) {
Expand All @@ -24,6 +24,11 @@ export function get(key) {
}
}

// if default value is set and key is not found in localStorage, set default value
if (!result[key] && defaultValue !== null) {
result[key] = defaultValue;
}

return result;
}

Expand Down
1 change: 1 addition & 0 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function cleanupLocalStorage() {
'selected_board',
'unifiedConfigLast',
'unifiedSourceCache',
'erase_chip',
];

for (const key in localStorage) {
Expand Down
8 changes: 2 additions & 6 deletions src/js/tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,8 @@ firmware_flasher.initialize = function (callback) {
self.isFlashing = false;
}

let result = getConfig('erase_chip');
if (result.erase_chip) {
$('input.erase_chip').prop('checked', true);
} else {
$('input.erase_chip').prop('checked', false);
}
let result = getConfig('erase_chip', true);
$('input.erase_chip').prop('checked', result.erase_chip);

$('input.erase_chip').change(function () {
setConfig({'erase_chip': $(this).is(':checked')});
Expand Down
2 changes: 1 addition & 1 deletion src/tabs/firmware_flasher.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<td>
</td>
</tr>
<tr class="expertOptions option manual_baud_rate noboarder">
<tr class="expertOptions option manual_baud_rate noborder">
<td>
<label>
<input class="flash_manual_baud toggle" type="checkbox" />
Expand Down
2 changes: 1 addition & 1 deletion src/tabs/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
<td i18n="initialSetupDrawing"></td>
<td class="bat-mah-drawing">0.00 A</td>
</tr>
<tr class="noboarder">
<tr class="noborder">
<td i18n="initialSetupRSSI"></td>
<td class="rssi">0 %</td>
</tr>
Expand Down

0 comments on commit b67ffa2

Please sign in to comment.