preferences.tsx 658 B

123456789101112131415161718192021222324
  1. import Cookies from 'js-cookie';
  2. import PreferencesActions from '../actions/preferencesActions';
  3. const SIDEBAR_COOKIE_KEY = 'sidebar_collapsed';
  4. const COOKIE_ENABLED = '1';
  5. const COOKIE_DISABLED = '0';
  6. export function hideSidebar() {
  7. PreferencesActions.hideSidebar();
  8. Cookies.set(SIDEBAR_COOKIE_KEY, COOKIE_ENABLED);
  9. }
  10. export function showSidebar() {
  11. PreferencesActions.showSidebar();
  12. Cookies.set(SIDEBAR_COOKIE_KEY, COOKIE_DISABLED);
  13. }
  14. export function loadPreferencesState() {
  15. // Set initial "collapsed" state to true or false
  16. PreferencesActions.loadInitialState({
  17. collapsed: Cookies.get(SIDEBAR_COOKIE_KEY) === COOKIE_ENABLED,
  18. });
  19. }