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

Presets TAB

This commit is contained in:
Ivan Efimov 2021-11-23 19:38:48 -06:00
parent 41747c65b6
commit e63a5fe642
39 changed files with 3375 additions and 19 deletions

View file

@ -5,30 +5,31 @@
const ConfigStorage = {
// key can be one string, or array of strings
get: function(key, callback) {
let result = {};
if (Array.isArray(key)) {
let obj = {};
key.forEach(function (element) {
try {
obj = {...obj, ...JSON.parse(window.localStorage.getItem(element))};
result = {...result, ...JSON.parse(window.localStorage.getItem(element))};
} catch (e) {
// is okay
}
});
callback(obj);
callback?.(result);
} else {
const keyValue = window.localStorage.getItem(key);
if (keyValue) {
let obj = {};
try {
obj = JSON.parse(keyValue);
result = JSON.parse(keyValue);
} catch (e) {
// It's fine if we fail that parse
}
callback(obj);
callback?.(result);
} else {
callback({});
callback?.(result);
}
}
return result;
},
// set takes an object like {'userLanguageSelect':'DEFAULT'}
set: function(input) {