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 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // @flow
  2. import {
  3. ADD_MESSAGE,
  4. CLEAR_MESSAGES,
  5. CLOSE_CHAT,
  6. EDIT_MESSAGE,
  7. SEND_MESSAGE,
  8. SET_PRIVATE_MESSAGE_RECIPIENT,
  9. SET_IS_POLL_TAB_FOCUSED
  10. } from './actionTypes';
  11. /**
  12. * Adds a chat message to the collection of messages.
  13. *
  14. * @param {Object} messageDetails - The chat message to save.
  15. * @param {string} messageDetails.displayName - The displayName of the
  16. * participant that authored the message.
  17. * @param {boolean} messageDetails.hasRead - Whether or not to immediately mark
  18. * the message as read.
  19. * @param {string} messageDetails.message - The received message to display.
  20. * @param {string} messageDetails.messageType - The kind of message, such as
  21. * "error" or "local" or "remote".
  22. * @param {string} messageDetails.timestamp - A timestamp to display for when
  23. * the message was received.
  24. * @param {string} messageDetails.isReaction - Whether or not the
  25. * message is a reaction message.
  26. * @returns {{
  27. * type: ADD_MESSAGE,
  28. * displayName: string,
  29. * hasRead: boolean,
  30. * message: string,
  31. * messageType: string,
  32. * timestamp: string,
  33. * isReaction: boolean
  34. * }}
  35. */
  36. export function addMessage(messageDetails: Object) {
  37. return {
  38. type: ADD_MESSAGE,
  39. ...messageDetails
  40. };
  41. }
  42. /**
  43. * Edits an existing chat message.
  44. *
  45. * @param {Object} message - The chat message to edit/override. The messages will be matched from the state
  46. * comparing the messageId.
  47. * @returns {{
  48. * type: EDIT_MESSAGE,
  49. * message: Object
  50. * }}
  51. */
  52. export function editMessage(message: Object) {
  53. return {
  54. type: EDIT_MESSAGE,
  55. message
  56. };
  57. }
  58. /**
  59. * Clears the chat messages in Redux.
  60. *
  61. * @returns {{
  62. * type: CLEAR_MESSAGES
  63. * }}
  64. */
  65. export function clearMessages() {
  66. return {
  67. type: CLEAR_MESSAGES
  68. };
  69. }
  70. /**
  71. * Action to signal the closing of the chat dialog.
  72. *
  73. * @returns {{
  74. * type: CLOSE_CHAT
  75. * }}
  76. */
  77. export function closeChat() {
  78. return {
  79. type: CLOSE_CHAT
  80. };
  81. }
  82. /**
  83. * Sends a chat message to everyone in the conference.
  84. *
  85. * @param {string} message - The chat message to send out.
  86. * @param {boolean} ignorePrivacy - True if the privacy notification should be ignored.
  87. * @returns {{
  88. * type: SEND_MESSAGE,
  89. * ignorePrivacy: boolean,
  90. * message: string
  91. * }}
  92. */
  93. export function sendMessage(message: string, ignorePrivacy: boolean = false) {
  94. return {
  95. type: SEND_MESSAGE,
  96. ignorePrivacy,
  97. message
  98. };
  99. }
  100. /**
  101. * Initiates the sending of a private message to the supplied participant.
  102. *
  103. * @param {Participant} participant - The participant to set the recipient to.
  104. * @returns {{
  105. * participant: Participant,
  106. * type: SET_PRIVATE_MESSAGE_RECIPIENT
  107. * }}
  108. */
  109. export function setPrivateMessageRecipient(participant: Object) {
  110. return {
  111. participant,
  112. type: SET_PRIVATE_MESSAGE_RECIPIENT
  113. };
  114. }
  115. /**
  116. * Set the value of _isPollsTabFocused.
  117. *
  118. * @param {boolean} isPollsTabFocused - The new value for _isPollsTabFocused.
  119. * @returns {Function}
  120. */
  121. export function setIsPollsTabFocused(isPollsTabFocused: boolean) {
  122. return {
  123. isPollsTabFocused,
  124. type: SET_IS_POLL_TAB_FOCUSED
  125. };
  126. }