您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

reducer.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // @flow
  2. import { ReducerRegistry } from '../base/redux';
  3. import {
  4. TOGGLE_REACTIONS_VISIBLE,
  5. SET_REACTIONS_MESSAGE,
  6. CLEAR_REACTIONS_MESSAGE,
  7. SET_REACTION_QUEUE
  8. } from './actionTypes';
  9. /**
  10. * Returns initial state for reactions' part of Redux store.
  11. *
  12. * @private
  13. * @returns {{
  14. * visible: boolean,
  15. * message: string,
  16. * timeoutID: number,
  17. * queue: Array
  18. * }}
  19. */
  20. function _getInitialState() {
  21. return {
  22. /**
  23. * The indicator that determines whether the reactions menu is visible.
  24. *
  25. * @type {boolean}
  26. */
  27. visible: false,
  28. /**
  29. * A string that contains the message to be added to the chat.
  30. *
  31. * @type {string}
  32. */
  33. message: '',
  34. /**
  35. * A number, non-zero value which identifies the timer created by a call
  36. * to setTimeout().
  37. *
  38. * @type {number|null}
  39. */
  40. timeoutID: null,
  41. /**
  42. * The array of reactions to animate
  43. *
  44. * @type {Array}
  45. */
  46. queue: []
  47. };
  48. }
  49. ReducerRegistry.register(
  50. 'features/reactions',
  51. (state: Object = _getInitialState(), action: Object) => {
  52. switch (action.type) {
  53. case TOGGLE_REACTIONS_VISIBLE:
  54. return {
  55. ...state,
  56. visible: !state.visible
  57. };
  58. case SET_REACTIONS_MESSAGE:
  59. return {
  60. ...state,
  61. message: action.message,
  62. timeoutID: action.timeoutID
  63. };
  64. case CLEAR_REACTIONS_MESSAGE:
  65. return {
  66. ...state,
  67. message: '',
  68. timeoutID: null
  69. };
  70. case SET_REACTION_QUEUE: {
  71. return {
  72. ...state,
  73. queue: action.value
  74. };
  75. }
  76. }
  77. return state;
  78. });