aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/util/preferences.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/common/util/preferences.js')
-rw-r--r--modern/src/common/util/preferences.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/modern/src/common/util/preferences.js b/modern/src/common/util/preferences.js
new file mode 100644
index 00000000..aba3c82c
--- /dev/null
+++ b/modern/src/common/util/preferences.js
@@ -0,0 +1,15 @@
+import { useSelector } from 'react-redux';
+
+export const usePreference = (key, defaultValue) => useSelector((state) => {
+ if (state.session.server.forceSettings) {
+ return state.session.server[key] || state.session.user[key] || defaultValue;
+ }
+ return state.session.user[key] || state.session.server[key] || defaultValue;
+});
+
+export const useAttributePreference = (key, defaultValue) => useSelector((state) => {
+ if (state.session.server.forceSettings) {
+ return state.session.server.attributes[key] || state.session.user.attributes[key] || defaultValue;
+ }
+ return state.session.user.attributes[key] || state.session.server.attributes[key] || defaultValue;
+});