about summary refs log tree commit diff
path: root/app/assets/javascripts/components/reducers/settings.jsx
blob: 820af99edb406f1b5fdc5e178ddc02c832b5102f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { SETTING_CHANGE } from '../actions/settings';
import { STORE_HYDRATE } from '../actions/store';
import Immutable from 'immutable';

const initialState = Immutable.Map({
  onboarded: false,

  home: Immutable.Map({
    shows: Immutable.Map({
      reblog: true,
      reply: true
    })
  }),

  notifications: Immutable.Map({
    alerts: Immutable.Map({
      follow: true,
      favourite: true,
      reblog: true,
      mention: true
    }),

    shows: Immutable.Map({
      follow: true,
      favourite: true,
      reblog: true,
      mention: true
    }),

    sounds: Immutable.Map({
      follow: true,
      favourite: true,
      reblog: true,
      mention: true
    })
  })
});

export default function settings(state = initialState, action) {
  switch(action.type) {
  case STORE_HYDRATE:
    return state.mergeDeep(action.state.get('settings'));
  case SETTING_CHANGE:
    return state.setIn(action.key, action.value);
  default:
    return state;
  }
};