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.

actions.any.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // @flow
  2. import {
  3. ADD_REACTION_BUFFER,
  4. ADD_REACTION_MESSAGE,
  5. FLUSH_REACTION_BUFFER,
  6. PUSH_REACTIONS,
  7. SEND_REACTIONS,
  8. SET_REACTION_QUEUE
  9. } from './actionTypes';
  10. import { type ReactionEmojiProps } from './constants';
  11. /**
  12. * Sets the reaction queue.
  13. *
  14. * @param {Array} value - The new queue.
  15. * @returns {Function}
  16. */
  17. export function setReactionQueue(value: Array<ReactionEmojiProps>) {
  18. return {
  19. type: SET_REACTION_QUEUE,
  20. value
  21. };
  22. }
  23. /**
  24. * Removes a reaction from the queue.
  25. *
  26. * @param {number} uid - Id of the reaction to be removed.
  27. * @returns {void}
  28. */
  29. export function removeReaction(uid: number) {
  30. return (dispatch: Function, getState: Function) => {
  31. const queue = getState()['features/reactions'].queue;
  32. dispatch(setReactionQueue(queue.filter(reaction => reaction.uid !== uid)));
  33. };
  34. }
  35. /**
  36. * Sends the reactions buffer to everyone in the conference.
  37. *
  38. * @returns {{
  39. * type: SEND_REACTION
  40. * }}
  41. */
  42. export function sendReactions() {
  43. return {
  44. type: SEND_REACTIONS
  45. };
  46. }
  47. /**
  48. * Adds a reaction to the local buffer.
  49. *
  50. * @param {string} reaction - The reaction to be added.
  51. * @returns {{
  52. * type: ADD_REACTION_BUFFER,
  53. * reaction: string
  54. * }}
  55. */
  56. export function addReactionToBuffer(reaction: string) {
  57. return {
  58. type: ADD_REACTION_BUFFER,
  59. reaction
  60. };
  61. }
  62. /**
  63. * Clears the reaction buffer.
  64. *
  65. * @returns {{
  66. * type: FLUSH_REACTION_BUFFER
  67. * }}
  68. */
  69. export function flushReactionBuffer() {
  70. return {
  71. type: FLUSH_REACTION_BUFFER
  72. };
  73. }
  74. /**
  75. * Adds a reaction message to the chat.
  76. *
  77. * @param {string} message - The reaction message.
  78. * @returns {{
  79. * type: ADD_REACTION_MESSAGE,
  80. * message: string
  81. * }}
  82. */
  83. export function addReactionsToChat(message: string) {
  84. return {
  85. type: ADD_REACTION_MESSAGE,
  86. message
  87. };
  88. }
  89. /**
  90. * Adds reactions to the animation queue.
  91. *
  92. * @param {Array} reactions - The reactions to be animated.
  93. * @returns {{
  94. * type: PUSH_REACTIONS,
  95. * reactions: Array
  96. * }}
  97. */
  98. export function pushReactions(reactions: Array<string>) {
  99. return {
  100. type: PUSH_REACTIONS,
  101. reactions
  102. };
  103. }