2024-02-06 21:12:25 +08:00
|
|
|
import React from 'react';
|
2024-06-11 22:04:02 +08:00
|
|
|
import { useMutation, useReactiveVar } from '@apollo/client';
|
2024-02-06 21:12:25 +08:00
|
|
|
import LeaveMeetingButton from './component';
|
|
|
|
import { layoutSelectInput, layoutSelect } from '../../layout/context';
|
|
|
|
import { SMALL_VIEWPORT_BREAKPOINT } from '../../layout/enums';
|
2024-04-05 20:42:32 +08:00
|
|
|
import { USER_LEAVE_MEETING } from '/imports/ui/core/graphql/mutations/userMutations';
|
2024-06-06 21:50:03 +08:00
|
|
|
import { useStorageKey } from '/imports/ui/services/storage/hooks';
|
2024-06-11 22:04:02 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
|
|
|
import connectionStatus from '/imports/ui/core/graphql/singletons/connectionStatus';
|
|
|
|
import useMeeting from '/imports/ui/core/hooks/useMeeting';
|
|
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
2024-02-06 21:12:25 +08:00
|
|
|
|
|
|
|
const LeaveMeetingButtonContainer = (props) => {
|
2024-06-11 22:04:02 +08:00
|
|
|
const {
|
|
|
|
data: currentUser,
|
|
|
|
} = useCurrentUser((u) => ({
|
|
|
|
isModerator: u.isModerator,
|
|
|
|
}));
|
|
|
|
|
|
|
|
const {
|
|
|
|
data: meeting,
|
|
|
|
} = useMeeting((m) => ({
|
|
|
|
isBreakout: m.isBreakout,
|
|
|
|
}));
|
|
|
|
|
|
|
|
const { isMobile } = deviceInfo;
|
2024-02-06 21:12:25 +08:00
|
|
|
const isRTL = layoutSelect((i) => i.isRTL);
|
2024-04-05 20:42:32 +08:00
|
|
|
const [userLeaveMeeting] = useMutation(USER_LEAVE_MEETING);
|
2024-06-06 21:50:03 +08:00
|
|
|
const isDropdownOpen = useStorageKey('dropdownOpen');
|
2024-02-06 21:12:25 +08:00
|
|
|
|
2024-06-11 22:04:02 +08:00
|
|
|
const connected = useReactiveVar(connectionStatus.getConnectedStatusVar());
|
|
|
|
const amIModerator = currentUser?.isModerator;
|
|
|
|
const isBreakoutRoom = meeting?.isBreakout;
|
2024-02-06 21:12:25 +08:00
|
|
|
return (
|
2024-04-05 20:42:32 +08:00
|
|
|
<LeaveMeetingButton {...
|
|
|
|
{
|
2024-09-11 04:10:28 +08:00
|
|
|
ismobile: isMobile,
|
2024-06-11 22:04:02 +08:00
|
|
|
isRTL,
|
|
|
|
userLeaveMeeting,
|
|
|
|
isDropdownOpen,
|
|
|
|
amIModerator,
|
|
|
|
connected,
|
|
|
|
isBreakoutRoom,
|
|
|
|
...props,
|
2024-04-05 20:42:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/>
|
2024-02-06 21:12:25 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-06-11 22:04:02 +08:00
|
|
|
export default LeaveMeetingButtonContainer;
|