aboutsummaryrefslogtreecommitdiff
path: root/app/features/settings/functions.js
diff options
context:
space:
mode:
authorSaúl Ibarra Corretgé <s@saghul.net>2020-04-14 10:35:33 +0200
committerSaúl Ibarra Corretgé <s@saghul.net>2020-04-14 13:21:19 +0200
commitb72ea5a1237269f2a657cdc17d40238ad77c420c (patch)
treea1e0d126516d1ad47803435735ad4ce46652383e /app/features/settings/functions.js
parent2794692cbf43e17eac3ec87b72635315d6f919e1 (diff)
Fix show AoT window default value
Diffstat (limited to 'app/features/settings/functions.js')
-rw-r--r--app/features/settings/functions.js20
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;
+}