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.

46 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. side_arm_reply_mode : 'keep',
  12. collapsed : ImmutableMap({
  13. enabled : true,
  14. auto : ImmutableMap({
  15. all : false,
  16. notifications : true,
  17. lengthy : true,
  18. reblogs : false,
  19. replies : false,
  20. media : false,
  21. }),
  22. backgrounds : ImmutableMap({
  23. user_backgrounds : false,
  24. preview_images : false,
  25. }),
  26. }),
  27. media : ImmutableMap({
  28. letterbox : true,
  29. fullwidth : true,
  30. }),
  31. });
  32. const hydrate = (state, localSettings) => state.mergeDeep(localSettings);
  33. export default function localSettings(state = initialState, action) {
  34. switch(action.type) {
  35. case STORE_HYDRATE:
  36. return hydrate(state, action.state.get('local_settings'));
  37. case LOCAL_SETTING_CHANGE:
  38. return state.setIn(action.key, action.value);
  39. default:
  40. return state;
  41. }
  42. };