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.

reducer.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { ReducerRegistry } from '../base/redux';
  2. import {
  3. ADD_GIF_FOR_PARTICIPANT,
  4. HIDE_GIF_FOR_PARTICIPANT,
  5. REMOVE_GIF_FOR_PARTICIPANT,
  6. SET_GIF_DRAWER_VISIBILITY,
  7. SET_GIF_MENU_VISIBILITY
  8. } from './actionTypes';
  9. const initialState = {
  10. drawerVisible: false,
  11. gifList: new Map(),
  12. menuOpen: false
  13. };
  14. ReducerRegistry.register(
  15. 'features/gifs',
  16. (state = initialState, action) => {
  17. switch (action.type) {
  18. case ADD_GIF_FOR_PARTICIPANT: {
  19. const newList = state.gifList;
  20. newList.set(action.participantId, {
  21. gifUrl: action.gifUrl,
  22. timeoutID: action.timeoutID
  23. });
  24. return {
  25. ...state,
  26. gifList: newList
  27. };
  28. }
  29. case REMOVE_GIF_FOR_PARTICIPANT: {
  30. const newList = state.gifList;
  31. newList.delete(action.participantId);
  32. return {
  33. ...state,
  34. gifList: newList
  35. };
  36. }
  37. case HIDE_GIF_FOR_PARTICIPANT: {
  38. const newList = state.gifList;
  39. const gif = state.gifList.get(action.participantId);
  40. newList.set(action.participantId, {
  41. gifUrl: gif.gifUrl,
  42. timeoutID: action.timeoutID
  43. });
  44. return {
  45. ...state,
  46. gifList: newList
  47. };
  48. }
  49. case SET_GIF_DRAWER_VISIBILITY:
  50. return {
  51. ...state,
  52. drawerVisible: action.visible
  53. };
  54. case SET_GIF_MENU_VISIBILITY:
  55. return {
  56. ...state,
  57. menuOpen: action.visible
  58. };
  59. }
  60. return state;
  61. });