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

actions.web.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import VideoLayout from '../../../modules/UI/videolayout/VideoLayout';
  4. import { getParticipantById } from '../base/participants/functions';
  5. import { OPEN_CHAT } from './actionTypes';
  6. import { closeChat } from './actions.any';
  7. export * from './actions.any';
  8. /**
  9. * Displays the chat panel.
  10. *
  11. * @param {Object} participant - The recipient for the private chat.
  12. * @returns {{
  13. * participant: Participant,
  14. * type: OPEN_CHAT
  15. * }}
  16. */
  17. export function openChat(participant: Object) {
  18. return function(dispatch: (Object) => Object) {
  19. dispatch({
  20. participant,
  21. type: OPEN_CHAT
  22. });
  23. };
  24. }
  25. /**
  26. * Displays the chat panel for a participant identified by an id.
  27. *
  28. * @param {string} id - The id of the participant.
  29. * @returns {{
  30. * participant: Participant,
  31. * type: OPEN_CHAT
  32. * }}
  33. */
  34. export function openChatById(id: string) {
  35. return function(dispatch: (Object) => Object, getState: Function) {
  36. const participant = getParticipantById(getState(), id);
  37. return dispatch({
  38. participant,
  39. type: OPEN_CHAT
  40. });
  41. };
  42. }
  43. /**
  44. * Toggles display of the chat panel.
  45. *
  46. * @returns {Function}
  47. */
  48. export function toggleChat() {
  49. return (dispatch: Dispatch<any>, getState: Function) => {
  50. const isOpen = getState()['features/chat'].isOpen;
  51. if (isOpen) {
  52. dispatch(closeChat());
  53. } else {
  54. dispatch(openChat());
  55. }
  56. // Recompute the large video size whenever we toggle the chat, as it takes chat state into account.
  57. VideoLayout.onResize();
  58. };
  59. }