about summary refs log tree commit diff
path: root/app/javascript/mastodon/reducers/settings.js
blob: ababd49839880ff9a13f6476de90a4915c6ee0f3 (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
49
50
51
52
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,
    }),

    regex: Immutable.Map({
      body: '',
    }),
  }),

  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;
  }
};