aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/preferences.js
blob: aba3c82c46a0dd9a855b8dd9cdb6c4bf87b7cbf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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;
  }
  return state.session.user[key] || state.session.server[key] || 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;
  }
  return state.session.user.attributes[key] || state.session.server.attributes[key] || defaultValue;
});