You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

  1. // Package imports.
  2. import { Map as ImmutableMap } from 'immutable';
  3. // Our imports.
  4. import { STORE_HYDRATE } from 'flavours/glitch/actions/store';
  5. import { LOCAL_SETTING_CHANGE } from 'flavours/glitch/actions/local_settings';
  6. const initialState = ImmutableMap({
  7. layout : 'auto',
  8. stretch : true,
  9. navbar_under : false,
  10. side_arm : 'none',
  11. collapsed : ImmutableMap({
  12. enabled : true,
  13. auto : ImmutableMap({
  14. all : false,
  15. notifications : true,
  16. lengthy : true,
  17. reblogs : false,
  18. replies : false,
  19. media : false,
  20. }),
  21. backgrounds : ImmutableMap({
  22. user_backgrounds : false,
  23. preview_images : false,
  24. }),
  25. }),
  26. media : ImmutableMap({
  27. letterbox : true,
  28. fullwidth : true,
  29. }),
  30. });
  31. const hydrate = (state, localSettings) => state.mergeDeep(localSettings);
  32. export default function localSettings(state = initialState, action) {
  33. switch(action.type) {
  34. case STORE_HYDRATE:
  35. return hydrate(state, action.state.get('local_settings'));
  36. case LOCAL_SETTING_CHANGE:
  37. return state.setIn(action.key, action.value);
  38. default:
  39. return state;
  40. }
  41. };