You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.native.js 2.6KB

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