simplify settings

This commit is contained in:
Jan Prochazka
2021-04-18 10:40:33 +02:00
parent e97388e14b
commit cacd6ae849
5 changed files with 37 additions and 19 deletions

View File

@@ -1,6 +1,8 @@
import _ from 'lodash';
import { getCurrentSettings } from '../stores';
export function getIntSettingsValue(settings, name, defaultValue, min = null, max = null) {
export function getIntSettingsValue(name, defaultValue, min = null, max = null) {
const settings = getCurrentSettings();
const parsed = parseInt(settings[name]);
if (_.isNaN(parsed)) {
return defaultValue;
@@ -12,3 +14,10 @@ export function getIntSettingsValue(settings, name, defaultValue, min = null, ma
}
return defaultValue;
}
export function getBoolSettingsValue(name, defaultValue) {
const settings = getCurrentSettings();
const res = settings[name];
if (res == null) return defaultValue;
return !!res;
}