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.

HangupMenu.tsx 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* eslint-disable lines-around-comment */
  2. import React, { useCallback } from 'react';
  3. import { View } from 'react-native';
  4. import { useDispatch, useSelector } from 'react-redux';
  5. import { createBreakoutRoomsEvent, createToolbarEvent } from '../../../analytics/AnalyticsEvents';
  6. import { sendAnalytics } from '../../../analytics/functions';
  7. // @ts-ignore
  8. import { appNavigate } from '../../../app/actions';
  9. import { IReduxState } from '../../../app/types';
  10. // @ts-ignore
  11. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  12. // @ts-ignore
  13. import { endConference } from '../../../base/conference';
  14. import { hideSheet } from '../../../base/dialog/actions';
  15. // @ts-ignore
  16. import BottomSheet from '../../../base/dialog/components/native/BottomSheet';
  17. import { PARTICIPANT_ROLE } from '../../../base/participants/constants';
  18. import { getLocalParticipant } from '../../../base/participants/functions';
  19. import Button from '../../../base/ui/components/native/Button';
  20. import { BUTTON_TYPES } from '../../../base/ui/constants';
  21. import { moveToRoom } from '../../../breakout-rooms/actions';
  22. import { isInBreakoutRoom } from '../../../breakout-rooms/functions';
  23. /**
  24. * Menu presenting options to leave a room or meeting and to end meeting.
  25. *
  26. * @returns {JSX.Element} - The hangup menu.
  27. */
  28. function HangupMenu() {
  29. const dispatch = useDispatch();
  30. const _styles = useSelector(state => ColorSchemeRegistry.get(state, 'Toolbox'));
  31. const inBreakoutRoom = useSelector(isInBreakoutRoom);
  32. const isModerator = useSelector((state: IReduxState) =>
  33. getLocalParticipant(state)?.role === PARTICIPANT_ROLE.MODERATOR);
  34. const { DESTRUCTIVE, SECONDARY } = BUTTON_TYPES;
  35. const handleEndConference = useCallback(() => {
  36. dispatch(hideSheet());
  37. sendAnalytics(createToolbarEvent('endmeeting'));
  38. dispatch(endConference());
  39. }, [ hideSheet ]);
  40. const handleLeaveConference = useCallback(() => {
  41. dispatch(hideSheet());
  42. sendAnalytics(createToolbarEvent('hangup'));
  43. dispatch(appNavigate(undefined));
  44. }, [ hideSheet ]);
  45. const handleLeaveBreakoutRoom = useCallback(() => {
  46. dispatch(hideSheet());
  47. sendAnalytics(createBreakoutRoomsEvent('leave'));
  48. dispatch(moveToRoom());
  49. }, [ hideSheet ]);
  50. return (
  51. <BottomSheet>
  52. <View style = { _styles.hangupMenuContainer }>
  53. { isModerator && <Button
  54. accessibilityLabel = 'toolbar.endConference'
  55. labelKey = 'toolbar.endConference'
  56. onClick = { handleEndConference }
  57. style = { _styles.hangupButton }
  58. type = { DESTRUCTIVE } /> }
  59. <Button
  60. accessibilityLabel = 'toolbar.leaveConference'
  61. labelKey = 'toolbar.leaveConference'
  62. onClick = { handleLeaveConference }
  63. style = { _styles.hangupButton }
  64. type = { SECONDARY } />
  65. { inBreakoutRoom && <Button
  66. accessibilityLabel = 'breakoutRooms.actions.leaveBreakoutRoom'
  67. labelKey = 'breakoutRooms.actions.leaveBreakoutRoom'
  68. onClick = { handleLeaveBreakoutRoom }
  69. style = { _styles.hangupButton }
  70. type = { SECONDARY } /> }
  71. </View>
  72. </BottomSheet>
  73. );
  74. }
  75. export default HangupMenu;