diff options
Diffstat (limited to 'app/features/settings/functions.js')
-rw-r--r-- | app/features/settings/functions.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/features/settings/functions.js b/app/features/settings/functions.js new file mode 100644 index 0000000..b3a7392 --- /dev/null +++ b/app/features/settings/functions.js @@ -0,0 +1,20 @@ +// @flow + +/** + * Get's the value for the given setting, providing a default value. + * + * @param {Object} state - The redux state. + * @param {string} setting - The name for the desired setting. + * @param {*} defaultValue - The default value, in case the setting is + * undefined. + * @returns {*} The setting value. + */ +export function getSetting(state: Object, setting: string, defaultValue: any) { + const value = state.settings[setting]; + + if (typeof value === 'undefined') { + return defaultValue; + } + + return value; +} |