diff options
Diffstat (limited to 'modern/src/common')
-rw-r--r-- | modern/src/common/attributes/useCommonUserAttributes.js | 4 | ||||
-rw-r--r-- | modern/src/common/util/preferences.js | 18 |
2 files changed, 10 insertions, 12 deletions
diff --git a/modern/src/common/attributes/useCommonUserAttributes.js b/modern/src/common/attributes/useCommonUserAttributes.js index 845ab799..cef6daf8 100644 --- a/modern/src/common/attributes/useCommonUserAttributes.js +++ b/modern/src/common/attributes/useCommonUserAttributes.js @@ -25,10 +25,6 @@ export default (t) => useMemo(() => ({ name: t('mapActive'), type: 'string', }, - selectedMapStyle: { - name: t('mapDefault'), - type: 'string', - }, devicePrimary: { name: t('devicePrimaryInfo'), type: 'string', diff --git a/modern/src/common/util/preferences.js b/modern/src/common/util/preferences.js index fb8bb4f2..229b6f17 100644 --- a/modern/src/common/util/preferences.js +++ b/modern/src/common/util/preferences.js @@ -1,19 +1,21 @@ import { useSelector } from 'react-redux'; +const containsProperty = (object, key) => object.hasOwnProperty(key) && object[key] !== null; + export const usePreference = (key, defaultValue) => useSelector((state) => { if (state.session.server.forceSettings) { - if (state.session.server.hasOwnProperty(key)) { + if (containsProperty(state.session.server, key)) { return state.session.server[key]; } - if (state.session.user.hasOwnProperty(key)) { + if (containsProperty(state.session.user, key)) { return state.session.user[key]; } return defaultValue; } - if (state.session.user.hasOwnProperty(key)) { + if (containsProperty(state.session.user, key)) { return state.session.user[key]; } - if (state.session.server.hasOwnProperty(key)) { + if (containsProperty(state.session.server, key)) { return state.session.server[key]; } return defaultValue; @@ -21,18 +23,18 @@ export const usePreference = (key, defaultValue) => useSelector((state) => { export const useAttributePreference = (key, defaultValue) => useSelector((state) => { if (state.session.server.forceSettings) { - if (state.session.server.attributes.hasOwnProperty(key)) { + if (containsProperty(state.session.server.attributes, key)) { return state.session.server.attributes[key]; } - if (state.session.user.attributes.hasOwnProperty(key)) { + if (containsProperty(state.session.user.attributes, key)) { return state.session.user.attributes[key]; } return defaultValue; } - if (state.session.user.attributes.hasOwnProperty(key)) { + if (containsProperty(state.session.user.attributes, key)) { return state.session.user.attributes[key]; } - if (state.session.server.attributes.hasOwnProperty(key)) { + if (containsProperty(state.session.server.attributes, key)) { return state.session.server.attributes[key]; } return defaultValue; |