mutes.js 798 B

12345678910111213141516171819202122232425262728293031
  1. import Immutable from 'immutable';
  2. import {
  3. MUTES_INIT_MODAL,
  4. MUTES_TOGGLE_HIDE_NOTIFICATIONS,
  5. MUTES_CHANGE_DURATION,
  6. } from '../actions/mutes';
  7. const initialState = Immutable.Map({
  8. new: Immutable.Map({
  9. account: null,
  10. notifications: true,
  11. duration: 0,
  12. }),
  13. });
  14. export default function mutes(state = initialState, action) {
  15. switch (action.type) {
  16. case MUTES_INIT_MODAL:
  17. return state.withMutations((state) => {
  18. state.setIn(['new', 'account'], action.account);
  19. state.setIn(['new', 'notifications'], true);
  20. });
  21. case MUTES_TOGGLE_HIDE_NOTIFICATIONS:
  22. return state.updateIn(['new', 'notifications'], (old) => !old);
  23. case MUTES_CHANGE_DURATION:
  24. return state.setIn(['new', 'duration'], Number(action.duration));
  25. default:
  26. return state;
  27. }
  28. }