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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. * @returns {{
  24. * type: ADD_MESSAGE,
  25. * displayName: string,
  26. * hasRead: boolean,
  27. * message: string,
  28. * messageType: string,
  29. * timestamp: string,
  30. * }}
  31. */
  32. export function addMessage(messageDetails: Object) {
  33. return {
  34. type: ADD_MESSAGE,
  35. ...messageDetails
  36. };
  37. }
  38. /**
  39. * Clears the chat messages in Redux.
  40. *
  41. * @returns {{
  42. * type: CLEAR_MESSAGES
  43. * }}
  44. */
  45. export function clearMessages() {
  46. return {
  47. type: CLEAR_MESSAGES
  48. };
  49. }
  50. /**
  51. * Action to signal the closing of the chat dialog.
  52. *
  53. * @returns {{
  54. * type: CLOSE_CHAT
  55. * }}
  56. */
  57. export function closeChat() {
  58. return {
  59. type: CLOSE_CHAT
  60. };
  61. }
  62. /**
  63. * Sends a chat message to everyone in the conference.
  64. *
  65. * @param {string} message - The chat message to send out.
  66. * @param {boolean} ignorePrivacy - True if the privacy notification should be ignored.
  67. * @returns {{
  68. * type: SEND_MESSAGE,
  69. * ignorePrivacy: boolean,
  70. * message: string
  71. * }}
  72. */
  73. export function sendMessage(message: string, ignorePrivacy: boolean = false) {
  74. return {
  75. type: SEND_MESSAGE,
  76. ignorePrivacy,
  77. message
  78. };
  79. }
  80. /**
  81. * Initiates the sending of a private message to the supplied participant.
  82. *
  83. * @param {Participant} participant - The participant to set the recipient to.
  84. * @returns {{
  85. * participant: Participant,
  86. * type: SET_PRIVATE_MESSAGE_RECIPIENT
  87. * }}
  88. */
  89. export function setPrivateMessageRecipient(participant: Object) {
  90. return {
  91. participant,
  92. type: SET_PRIVATE_MESSAGE_RECIPIENT
  93. };
  94. }
  95. /**
  96. * Set the value of _isPollsTabFocused.
  97. *
  98. * @param {boolean} isPollsTabFocused - The new value for _isPollsTabFocused.
  99. * @returns {Function}
  100. */
  101. export function setIsPollsTabFocused(isPollsTabFocused: boolean) {
  102. return {
  103. isPollsTabFocused,
  104. type: SET_IS_POLL_TAB_FOCUSED
  105. };
  106. }