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.8KB

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