2023-09-16 02:42:02 +08:00
|
|
|
import React, { useContext } from 'react';
|
2020-04-02 06:54:47 +08:00
|
|
|
import ActionsDropdown from './component';
|
2022-05-13 21:42:19 +08:00
|
|
|
import { layoutSelectInput, layoutDispatch, layoutSelect } from '../../layout/context';
|
2024-01-16 22:19:11 +08:00
|
|
|
import { SMALL_VIEWPORT_BREAKPOINT, ACTIONS, PANELS } from '../../layout/enums';
|
2023-06-14 22:32:52 +08:00
|
|
|
import { isCameraAsContentEnabled, isTimerFeatureEnabled } from '/imports/ui/services/features';
|
2023-09-16 02:42:02 +08:00
|
|
|
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
|
2023-12-07 21:02:13 +08:00
|
|
|
import { useSubscription, useMutation } from '@apollo/client';
|
2024-04-25 04:18:21 +08:00
|
|
|
import { useShortcut } from '/imports/ui/core/hooks/useShortcut';
|
2023-10-17 21:20:24 +08:00
|
|
|
import {
|
|
|
|
PROCESSED_PRESENTATIONS_SUBSCRIPTION,
|
|
|
|
} from '/imports/ui/components/whiteboard/queries';
|
2023-12-07 21:02:13 +08:00
|
|
|
import { SET_PRESENTER } from '/imports/ui/core/graphql/mutations/userMutations';
|
2024-01-17 00:51:36 +08:00
|
|
|
import { TIMER_ACTIVATE, TIMER_DEACTIVATE } from '../../timer/mutations';
|
2023-12-07 21:02:13 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2024-01-23 20:51:14 +08:00
|
|
|
import { PRESENTATION_SET_CURRENT } from '../../presentation/mutations';
|
2021-05-18 04:25:07 +08:00
|
|
|
|
|
|
|
const ActionsDropdownContainer = (props) => {
|
2021-09-11 04:48:52 +08:00
|
|
|
const sidebarContent = layoutSelectInput((i) => i.sidebarContent);
|
|
|
|
const sidebarNavigation = layoutSelectInput((i) => i.sidebarNavigation);
|
2022-03-04 01:46:20 +08:00
|
|
|
const { width: browserWidth } = layoutSelectInput((i) => i.browser);
|
|
|
|
const isMobile = browserWidth <= SMALL_VIEWPORT_BREAKPOINT;
|
2021-09-11 04:48:52 +08:00
|
|
|
const layoutContextDispatch = layoutDispatch();
|
2022-05-13 21:42:19 +08:00
|
|
|
const isRTL = layoutSelect((i) => i.isRTL);
|
2023-11-29 02:31:28 +08:00
|
|
|
const { pluginsExtensibleAreasAggregatedState } = useContext(PluginsContext);
|
2023-09-16 02:42:02 +08:00
|
|
|
let actionButtonDropdownItems = [];
|
2023-11-29 02:31:28 +08:00
|
|
|
if (pluginsExtensibleAreasAggregatedState.actionButtonDropdownItems) {
|
|
|
|
actionButtonDropdownItems = [...pluginsExtensibleAreasAggregatedState.actionButtonDropdownItems];
|
2023-09-16 02:42:02 +08:00
|
|
|
}
|
2021-05-19 22:51:31 +08:00
|
|
|
|
2024-04-25 04:18:21 +08:00
|
|
|
const openActions = useShortcut('openActions');
|
|
|
|
|
2023-10-17 21:20:24 +08:00
|
|
|
const { data: presentationData } = useSubscription(PROCESSED_PRESENTATIONS_SUBSCRIPTION);
|
|
|
|
const presentations = presentationData?.pres_presentation || [];
|
|
|
|
|
2023-12-07 21:02:13 +08:00
|
|
|
const [setPresenter] = useMutation(SET_PRESENTER);
|
2024-01-16 22:19:11 +08:00
|
|
|
const [timerActivate] = useMutation(TIMER_ACTIVATE);
|
2024-01-17 00:51:36 +08:00
|
|
|
const [timerDeactivate] = useMutation(TIMER_DEACTIVATE);
|
2024-01-23 20:51:14 +08:00
|
|
|
const [presentationSetCurrent] = useMutation(PRESENTATION_SET_CURRENT);
|
2023-12-07 21:02:13 +08:00
|
|
|
|
|
|
|
const handleTakePresenter = () => {
|
|
|
|
setPresenter({ variables: { userId: Auth.userID } });
|
|
|
|
};
|
|
|
|
|
2024-01-23 20:51:14 +08:00
|
|
|
const setPresentation = (presentationId) => {
|
|
|
|
presentationSetCurrent({ variables: { presentationId } });
|
|
|
|
};
|
|
|
|
|
2024-01-16 22:19:11 +08:00
|
|
|
const activateTimer = () => {
|
2024-05-29 21:26:11 +08:00
|
|
|
const TIMER_CONFIG = window.meetingClientSettings.public.timer;
|
|
|
|
const MILLI_IN_MINUTE = 60000;
|
2024-01-16 22:19:11 +08:00
|
|
|
const stopwatch = true;
|
|
|
|
const running = false;
|
|
|
|
const time = TIMER_CONFIG.time * MILLI_IN_MINUTE;
|
|
|
|
|
|
|
|
timerActivate({ variables: { stopwatch, running, time } });
|
|
|
|
|
2024-01-18 19:33:43 +08:00
|
|
|
setTimeout(() => {
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_IS_OPEN,
|
|
|
|
value: true,
|
|
|
|
});
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_SIDEBAR_CONTENT_PANEL,
|
|
|
|
value: PANELS.TIMER,
|
|
|
|
});
|
|
|
|
}, 500);
|
2024-01-16 22:19:11 +08:00
|
|
|
};
|
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
return (
|
2023-06-14 22:32:52 +08:00
|
|
|
<ActionsDropdown
|
|
|
|
{...{
|
|
|
|
layoutContextDispatch,
|
|
|
|
sidebarContent,
|
|
|
|
sidebarNavigation,
|
|
|
|
isMobile,
|
|
|
|
isRTL,
|
2023-09-16 02:42:02 +08:00
|
|
|
actionButtonDropdownItems,
|
2023-10-17 21:20:24 +08:00
|
|
|
presentations,
|
|
|
|
isTimerFeatureEnabled: isTimerFeatureEnabled(),
|
|
|
|
isDropdownOpen: Session.get('dropdownOpen'),
|
2024-01-23 20:51:14 +08:00
|
|
|
setPresentation,
|
2023-10-17 21:20:24 +08:00
|
|
|
isCameraAsContentEnabled: isCameraAsContentEnabled(),
|
2023-12-07 21:02:13 +08:00
|
|
|
handleTakePresenter,
|
2024-01-16 22:19:11 +08:00
|
|
|
activateTimer,
|
2024-01-17 00:51:36 +08:00
|
|
|
deactivateTimer: timerDeactivate,
|
2024-04-25 04:18:21 +08:00
|
|
|
shortcuts: openActions,
|
2023-06-14 22:32:52 +08:00
|
|
|
...props,
|
|
|
|
}}
|
2021-05-19 22:51:31 +08:00
|
|
|
/>
|
|
|
|
);
|
2021-05-18 04:25:07 +08:00
|
|
|
};
|
2020-04-02 06:54:47 +08:00
|
|
|
|
2023-10-17 21:20:24 +08:00
|
|
|
export default ActionsDropdownContainer;
|