diff options
Diffstat (limited to 'modern/src/common/util')
-rw-r--r-- | modern/src/common/util/preferences.js | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/modern/src/common/util/preferences.js b/modern/src/common/util/preferences.js index aba3c82c..fb8bb4f2 100644 --- a/modern/src/common/util/preferences.js +++ b/modern/src/common/util/preferences.js @@ -2,14 +2,38 @@ 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; + if (state.session.server.hasOwnProperty(key)) { + return state.session.server[key]; + } + if (state.session.user.hasOwnProperty(key)) { + return state.session.user[key]; + } + return defaultValue; } - return state.session.user[key] || state.session.server[key] || defaultValue; + if (state.session.user.hasOwnProperty(key)) { + return state.session.user[key]; + } + if (state.session.server.hasOwnProperty(key)) { + return state.session.server[key]; + } + return 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; + if (state.session.server.attributes.hasOwnProperty(key)) { + return state.session.server.attributes[key]; + } + if (state.session.user.attributes.hasOwnProperty(key)) { + return state.session.user.attributes[key]; + } + return defaultValue; + } + if (state.session.user.attributes.hasOwnProperty(key)) { + return state.session.user.attributes[key]; + } + if (state.session.server.attributes.hasOwnProperty(key)) { + return state.session.server.attributes[key]; } - return state.session.user.attributes[key] || state.session.server.attributes[key] || defaultValue; + return defaultValue; }); |