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

actions.js 1.5KB

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