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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // @flow
  2. import {
  3. ADD_REACTIONS_MESSAGE,
  4. CLEAR_REACTIONS_MESSAGE,
  5. PUSH_REACTION,
  6. SEND_REACTION,
  7. SET_REACTIONS_MESSAGE,
  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. * Appends the reactions message to the chat and resets the state.
  25. *
  26. * @returns {void}
  27. */
  28. export function flushReactionsToChat() {
  29. return {
  30. type: CLEAR_REACTIONS_MESSAGE
  31. };
  32. }
  33. /**
  34. * Adds a new reaction to the reactions message.
  35. *
  36. * @param {boolean} value - The new reaction.
  37. * @returns {Object}
  38. */
  39. export function addReactionsMessage(value: string) {
  40. return {
  41. type: SET_REACTIONS_MESSAGE,
  42. reaction: value
  43. };
  44. }
  45. /**
  46. * Adds a new reaction to the reactions message.
  47. *
  48. * @param {boolean} value - Reaction to be added to queue.
  49. * @returns {Object}
  50. */
  51. export function pushReaction(value: string) {
  52. return {
  53. type: PUSH_REACTION,
  54. reaction: value
  55. };
  56. }
  57. /**
  58. * Removes a reaction from the queue.
  59. *
  60. * @param {number} uid - Id of the reaction to be removed.
  61. * @returns {void}
  62. */
  63. export function removeReaction(uid: number) {
  64. return (dispatch: Function, getState: Function) => {
  65. const queue = getState()['features/reactions'].queue;
  66. dispatch(setReactionQueue(queue.filter(reaction => reaction.uid !== uid)));
  67. };
  68. }
  69. /**
  70. * Sends a reaction message to everyone in the conference.
  71. *
  72. * @param {string} reaction - The reaction to send out.
  73. * @returns {{
  74. * type: SEND_REACTION,
  75. * reaction: string
  76. * }}
  77. */
  78. export function sendReaction(reaction: string) {
  79. return {
  80. type: SEND_REACTION,
  81. reaction
  82. };
  83. }
  84. /**
  85. * Adds a reactions message to the chat.
  86. *
  87. * @param {string} message - The reactions message to add to chat.
  88. * @returns {{
  89. * type: ADD_REACTIONS_MESSAGE,
  90. * message: string
  91. * }}
  92. */
  93. export function addReactionsMessageToChat(message: string) {
  94. return {
  95. type: ADD_REACTIONS_MESSAGE,
  96. message
  97. };
  98. }