mutes.js 656 B

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