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

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