From cea47047f296b25794ebb06f679b590c0b42448e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 1 Nov 2020 20:57:02 -0800 Subject: Enable mapbox maps --- modern/src/common/preferences.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 modern/src/common/preferences.js (limited to 'modern/src/common/preferences.js') 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; + } + }); +}; -- cgit v1.2.3