您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import {
  2. ADD_MESSAGE,
  3. CLEAR_MESSAGES,
  4. SEND_MESSAGE,
  5. TOGGLE_CHAT
  6. } from './actionTypes';
  7. /**
  8. * Adds a chat message to the collection of messages.
  9. *
  10. * @param {Object} messageDetails - The chat message to save.
  11. * @param {string} messageDetails.displayName - The displayName of the
  12. * participant that authored the message.
  13. * @param {boolean} messageDetails.hasRead - Whether or not to immediately mark
  14. * the message as read.
  15. * @param {string} messageDetails.message - The received message to display.
  16. * @param {string} messageDetails.messageType - The kind of message, such as
  17. * "error" or "local" or "remote".
  18. * @param {string} messageDetails.timestamp - A timestamp to display for when
  19. * the message was received.
  20. * @returns {{
  21. * type: ADD_MESSAGE,
  22. * displayName: string,
  23. * hasRead: boolean,
  24. * message: string,
  25. * messageType: string,
  26. * timestamp: string,
  27. * }}
  28. */
  29. export function addMessage(messageDetails) {
  30. return {
  31. type: ADD_MESSAGE,
  32. ...messageDetails
  33. };
  34. }
  35. /**
  36. * Removes all stored chat messages.
  37. *
  38. * @returns {{
  39. * type: CLEAR_MESSAGES
  40. * }}
  41. */
  42. export function clearMessages() {
  43. return {
  44. type: CLEAR_MESSAGES
  45. };
  46. }
  47. /**
  48. * Sends a chat message to everyone in the conference.
  49. *
  50. * @param {string} message - The chat message to send out.
  51. * @returns {{
  52. * type: SEND_MESSAGE,
  53. * message: string
  54. * }}
  55. */
  56. export function sendMessage(message) {
  57. return {
  58. type: SEND_MESSAGE,
  59. message
  60. };
  61. }
  62. /**
  63. * Toggles display of the chat side panel.
  64. *
  65. * @returns {{
  66. * type: TOGGLE_CHAT
  67. * }}
  68. */
  69. export function toggleChat() {
  70. return {
  71. type: TOGGLE_CHAT
  72. };
  73. }