diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-01 20:57:02 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-01 20:57:02 -0800 |
commit | cea47047f296b25794ebb06f679b590c0b42448e (patch) | |
tree | da6d49cbb7da9db5f68ef37c931d0d4085286c93 /modern/src/common | |
parent | fb330f777ceb0e531699ea0842c0199622114288 (diff) | |
download | trackermap-web-cea47047f296b25794ebb06f679b590c0b42448e.tar.gz trackermap-web-cea47047f296b25794ebb06f679b590c0b42448e.tar.bz2 trackermap-web-cea47047f296b25794ebb06f679b590c0b42448e.zip |
Enable mapbox maps
Diffstat (limited to 'modern/src/common')
-rw-r--r-- | modern/src/common/preferences.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/modern/src/common/preferences.js b/modern/src/common/preferences.js new file mode 100644 index 00000000..24fe389a --- /dev/null +++ b/modern/src/common/preferences.js @@ -0,0 +1,21 @@ +import { useSelector } from 'react-redux'; + +export const usePreference = (key, defaultValue) => { + return useSelector(state => { + if (state.session.server.forceSettings) { + return state.session.server[key] || state.session.user[key] || defaultValue; + } else { + return state.session.user[key] || state.session.server[key] || defaultValue; + } + }); +}; + +export const useAttributePreference = (key, defaultValue) => { + return useSelector(state => { + if (state.session.server.forceSettings) { + return state.session.server.attributes[key] || state.session.user.attributes[key] || defaultValue; + } else { + return state.session.user.attributes[key] || state.session.server.attributes[key] || defaultValue; + } + }); +}; |