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

functions.native.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* @flow */
  2. import type { Dispatch } from 'redux';
  3. import { appNavigate } from '../app';
  4. import { toggleAudioMuted, toggleVideoMuted } from '../base/media';
  5. import { getLocalAudioTrack, getLocalVideoTrack } from '../base/tracks';
  6. /**
  7. * Maps (redux) actions to React component props.
  8. *
  9. * @param {Function} dispatch - Redux action dispatcher.
  10. * @returns {{
  11. * _onHangup: Function,
  12. * _onToggleAudio: Function,
  13. * _onToggleVideo: Function
  14. * }}
  15. * @private
  16. */
  17. export function abstractMapDispatchToProps(dispatch: Dispatch<*>): Object {
  18. return {
  19. /**
  20. * Dispatches action to leave the current conference.
  21. *
  22. * @private
  23. * @returns {void}
  24. * @type {Function}
  25. */
  26. _onHangup() {
  27. // XXX We don't know here which value is effectively/internally
  28. // used when there's no valid room name to join. It isn't our
  29. // business to know that anyway. The undefined value is our
  30. // expression of (1) the lack of knowledge & (2) the desire to no
  31. // longer have a valid room name to join.
  32. dispatch(appNavigate(undefined));
  33. },
  34. /**
  35. * Dispatches an action to toggle the mute state of the
  36. * audio/microphone.
  37. *
  38. * @private
  39. * @returns {Object} - Dispatched action.
  40. * @type {Function}
  41. */
  42. _onToggleAudio() {
  43. dispatch(toggleAudioMuted());
  44. },
  45. /**
  46. * Dispatches an action to toggle the mute state of the video/camera.
  47. *
  48. * @private
  49. * @returns {Object} - Dispatched action.
  50. * @type {Function}
  51. */
  52. _onToggleVideo() {
  53. dispatch(toggleVideoMuted());
  54. }
  55. };
  56. }
  57. /**
  58. * Maps parts of media state to component props.
  59. *
  60. * @param {Object} state - Redux state.
  61. * @protected
  62. * @returns {{
  63. * _audioMuted: boolean,
  64. * _videoMuted: boolean,
  65. * _visible: boolean
  66. * }}
  67. */
  68. export function abstractMapStateToProps(state: Object): Object {
  69. const tracks = state['features/base/tracks'];
  70. const { visible } = state['features/toolbox'];
  71. const audioTrack = getLocalAudioTrack(tracks);
  72. const videoTrack = getLocalVideoTrack(tracks);
  73. return {
  74. /**
  75. * Flag showing that audio is muted.
  76. *
  77. * @protected
  78. * @type {boolean}
  79. */
  80. _audioMuted: !audioTrack || audioTrack.muted,
  81. /**
  82. * Flag showing whether video is muted.
  83. *
  84. * @protected
  85. * @type {boolean}
  86. */
  87. _videoMuted: !videoTrack || videoTrack.muted,
  88. /**
  89. * Flag showing whether toolbox is visible.
  90. *
  91. * @protected
  92. * @type {boolean}
  93. */
  94. _visible: visible
  95. };
  96. }
  97. /**
  98. * Returns the button object corresponding to the given buttonName.
  99. *
  100. * @param {string} buttonName - The name of the button.
  101. * @param {Object} state - The current state.
  102. * @returns {Object} - The button object.
  103. */
  104. export function getButton(buttonName: string, state: Object) {
  105. const { primaryToolbarButtons, secondaryToolbarButtons }
  106. = state['features/toolbox'];
  107. return primaryToolbarButtons.get(buttonName)
  108. || secondaryToolbarButtons.get(buttonName);
  109. }