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.

62 lines
1.6 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. swipe_to_change_columns: true,
  11. side_arm : 'none',
  12. side_arm_reply_mode : 'keep',
  13. show_reply_count : false,
  14. always_show_spoilers_field: false,
  15. confirm_missing_media_description: false,
  16. confirm_before_clearing_draft: true,
  17. preselect_on_reply: true,
  18. inline_preview_cards: true,
  19. content_warnings : ImmutableMap({
  20. auto_unfold : false,
  21. filter : null,
  22. }),
  23. collapsed : ImmutableMap({
  24. enabled : true,
  25. auto : ImmutableMap({
  26. all : false,
  27. notifications : true,
  28. lengthy : true,
  29. reblogs : false,
  30. replies : false,
  31. media : false,
  32. }),
  33. backgrounds : ImmutableMap({
  34. user_backgrounds : false,
  35. preview_images : false,
  36. }),
  37. show_action_bar : true,
  38. }),
  39. media : ImmutableMap({
  40. letterbox : true,
  41. fullwidth : true,
  42. }),
  43. notifications : ImmutableMap({
  44. favicon_badge : false,
  45. tab_badge : true,
  46. }),
  47. });
  48. const hydrate = (state, localSettings) => state.mergeDeep(localSettings);
  49. export default function localSettings(state = initialState, action) {
  50. switch(action.type) {
  51. case STORE_HYDRATE:
  52. return hydrate(state, action.state.get('local_settings'));
  53. case LOCAL_SETTING_CHANGE:
  54. return state.setIn(action.key, action.value);
  55. default:
  56. return state;
  57. }
  58. };