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.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // @flow
  2. import {
  3. ADD_MESSAGE,
  4. CLEAR_MESSAGES,
  5. SEND_MESSAGE,
  6. SET_PRIVATE_MESSAGE_RECIPIENT,
  7. TOGGLE_CHAT
  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. * Sends a chat message to everyone in the conference.
  51. *
  52. * @param {string} message - The chat message to send out.
  53. * @param {boolean} ignorePrivacy - True if the privacy notification should be ignored.
  54. * @returns {{
  55. * type: SEND_MESSAGE,
  56. * ignorePrivacy: boolean,
  57. * message: string
  58. * }}
  59. */
  60. export function sendMessage(message: string, ignorePrivacy: boolean = false) {
  61. return {
  62. type: SEND_MESSAGE,
  63. ignorePrivacy,
  64. message
  65. };
  66. }
  67. /**
  68. * Initiates the sending of a private message to the supplied participant.
  69. *
  70. * @param {Participant} participant - The participant to set the recipient to.
  71. * @returns {{
  72. * participant: Participant,
  73. * type: SET_PRIVATE_MESSAGE_RECIPIENT
  74. * }}
  75. */
  76. export function setPrivateMessageRecipient(participant: Object) {
  77. return {
  78. participant,
  79. type: SET_PRIVATE_MESSAGE_RECIPIENT
  80. };
  81. }
  82. /**
  83. * Toggles display of the chat side panel.
  84. *
  85. * @returns {{
  86. * type: TOGGLE_CHAT
  87. * }}
  88. */
  89. export function toggleChat() {
  90. return {
  91. type: TOGGLE_CHAT
  92. };
  93. }