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 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // @flow
  2. import {
  3. ADD_MESSAGE,
  4. CLEAR_MESSAGES,
  5. SEND_MESSAGE,
  6. TOGGLE_CHAT
  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. * @returns {{
  53. * type: SEND_MESSAGE,
  54. * message: string
  55. * }}
  56. */
  57. export function sendMessage(message: string) {
  58. return {
  59. type: SEND_MESSAGE,
  60. message
  61. };
  62. }
  63. /**
  64. * Toggles display of the chat side panel.
  65. *
  66. * @returns {{
  67. * type: TOGGLE_CHAT
  68. * }}
  69. */
  70. export function toggleChat() {
  71. return {
  72. type: TOGGLE_CHAT
  73. };
  74. }