Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: betaflight/betaflight-configurator
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ecfe9f36856b34b2b4129b53bbbb2bea14763e63
Choose a base ref
..
head repository: betaflight/betaflight-configurator
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b2967721182a55ca859a50c47f34ee287dee1681
Choose a head ref
Showing with 8 additions and 7 deletions.
  1. +6 −1 src/js/ConfigStorage.js
  2. +2 −6 src/js/tabs/firmware_flasher.js
7 changes: 6 additions & 1 deletion src/js/ConfigStorage.js
Original file line number Diff line number Diff line change
@@ -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) {
@@ -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) {
result[key] = defaultValue;
}

return result;
}

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

let result = getConfig('erase_chip');
if (result.erase_chip === undefined) {
$('input.erase_chip').prop('checked', true);
} else {
$('input.erase_chip').prop('checked', result.erase_chip);
}
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')});