Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

actions.js 2.5KB

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