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

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