diff options
author | Anton Tananaev <anton@traccar.org> | 2022-10-28 06:48:33 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-10-28 06:48:33 -0700 |
commit | ef315b8e10329db80da1a97e96b3cc82481370ae (patch) | |
tree | 3a3e6366a98daf2e7c499422bdbcf94965917b28 /modern/src/common | |
parent | c000fa00d3a4b71a814864b9c805885f85bdd8dc (diff) | |
download | trackermap-web-ef315b8e10329db80da1a97e96b3cc82481370ae.tar.gz trackermap-web-ef315b8e10329db80da1a97e96b3cc82481370ae.tar.bz2 trackermap-web-ef315b8e10329db80da1a97e96b3cc82481370ae.zip |
Persist map geofences
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 | 32 |
2 files changed, 32 insertions, 4 deletions
diff --git a/modern/src/common/attributes/useCommonUserAttributes.js b/modern/src/common/attributes/useCommonUserAttributes.js index e64299bd..7fe2fcdf 100644 --- a/modern/src/common/attributes/useCommonUserAttributes.js +++ b/modern/src/common/attributes/useCommonUserAttributes.js @@ -1,6 +1,10 @@ import { useMemo } from 'react'; export default (t) => useMemo(() => ({ + mapGeofences: { + name: t('attributeShowGeofences'), + type: 'boolean', + }, locationIqKey: { name: t('mapLocationIqKey'), type: 'string', 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; }); |