mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-16 21:05:30 +03:00
Refactor config storage to use modules (#3189)
This commit is contained in:
parent
e6cbc22f6b
commit
2a4deed7cf
15 changed files with 148 additions and 117 deletions
|
@ -1,6 +1,7 @@
|
|||
import '../components/init.js';
|
||||
import { i18n } from './localization.js';
|
||||
import GUI from './gui.js';
|
||||
import { get as getConfig, set as setConfig } from './ConfigStorage.js';
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
|
@ -198,7 +199,7 @@ function startProcess() {
|
|||
const tabNameWithoutPrefix = tabName.substring(4);
|
||||
if (tabNameWithoutPrefix !== "cli") {
|
||||
// Don't store 'cli' otherwise you can never connect to another tab.
|
||||
ConfigStorage.set(
|
||||
setConfig(
|
||||
{lastTab: tabName},
|
||||
);
|
||||
}
|
||||
|
@ -494,14 +495,14 @@ function startProcess() {
|
|||
$("#log").removeClass('active');
|
||||
$("#tab-content-container").removeClass('logopen');
|
||||
$("#scrollicon").removeClass('active');
|
||||
ConfigStorage.set({'logopen': false});
|
||||
setConfig({'logopen': false});
|
||||
|
||||
state = false;
|
||||
} else {
|
||||
$("#log").addClass('active');
|
||||
$("#tab-content-container").addClass('logopen');
|
||||
$("#scrollicon").addClass('active');
|
||||
ConfigStorage.set({'logopen': true});
|
||||
setConfig({'logopen': true});
|
||||
|
||||
state = true;
|
||||
}
|
||||
|
@ -509,12 +510,12 @@ function startProcess() {
|
|||
$(this).data('state', state);
|
||||
});
|
||||
|
||||
let result = ConfigStorage.get('logopen');
|
||||
let result = getConfig('logopen');
|
||||
if (result.logopen) {
|
||||
$("#showlog").trigger('click');
|
||||
}
|
||||
|
||||
result = ConfigStorage.get('permanentExpertMode');
|
||||
result = getConfig('permanentExpertMode');
|
||||
const expertModeCheckbox = 'input[name="expertModeCheckbox"]';
|
||||
if (result.permanentExpertMode) {
|
||||
$(expertModeCheckbox).prop('checked', true);
|
||||
|
@ -534,10 +535,10 @@ function startProcess() {
|
|||
|
||||
$(expertModeCheckbox).trigger("change");
|
||||
|
||||
result = ConfigStorage.get('cliAutoComplete');
|
||||
result = getConfig('cliAutoComplete');
|
||||
CliAutoComplete.setEnabled(typeof result.cliAutoComplete === "undefined" || result.cliAutoComplete); // On by default
|
||||
|
||||
result = ConfigStorage.get('darkTheme');
|
||||
result = getConfig('darkTheme');
|
||||
if (result.darkTheme === undefined || typeof result.darkTheme !== "number") {
|
||||
// sets dark theme to auto if not manually changed
|
||||
setDarkTheme(2);
|
||||
|
@ -575,7 +576,7 @@ function checkForConfiguratorUpdates() {
|
|||
}
|
||||
|
||||
function notifyOutdatedVersion(releaseData) {
|
||||
const result = ConfigStorage.get('checkForConfiguratorUnstableVersions');
|
||||
const result = getConfig('checkForConfiguratorUnstableVersions');
|
||||
let showUnstableReleases = false;
|
||||
if (result.checkForConfiguratorUnstableVersions) {
|
||||
showUnstableReleases = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue