1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-26 17:55:24 +03:00

Change lexical scope configInsert and configStorage

This commit is contained in:
Mark Haslinghuis 2020-12-08 19:49:52 +01:00
parent 317f937fd5
commit e0bc8174d8
2 changed files with 22 additions and 24 deletions

View file

@ -2,11 +2,11 @@
// idea here is to abstract around the use of chrome.storage.local as it functions differently from "localStorage" and IndexedDB
// localStorage deals with strings, not objects, so the objects have been serialized.
var ConfigStorage = {
const ConfigStorage = {
// key can be one string, or array of strings
get: function(key, callback) {
if (Array.isArray(key)) {
var obj = {};
let obj = {};
key.forEach(function (element) {
try {
obj = {...obj, ...JSON.parse(window.localStorage.getItem(element))};
@ -16,9 +16,9 @@ var ConfigStorage = {
});
callback(obj);
} else {
var keyValue = window.localStorage.getItem(key);
const keyValue = window.localStorage.getItem(key);
if (keyValue) {
var obj = {};
let obj = {};
try {
obj = JSON.parse(keyValue);
} catch (e) {
@ -33,7 +33,7 @@ var ConfigStorage = {
// set takes an object like {'userLanguageSelect':'DEFAULT'}
set: function(input) {
Object.keys(input).forEach(function (element) {
var tmpObj = {};
const tmpObj = {};
tmpObj[element] = input[element];
window.localStorage.setItem(element, JSON.stringify(tmpObj));
});