2024-09-11 04:10:28 +08:00
|
|
|
import React, { useContext, useEffect, useState } from 'react';
|
2024-06-13 22:48:15 +08:00
|
|
|
import { useIntl } from 'react-intl';
|
|
|
|
import { useMutation, useReactiveVar } from '@apollo/client';
|
2018-09-14 02:09:30 +08:00
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
2018-11-13 06:09:04 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2016-05-20 21:46:30 +08:00
|
|
|
import ActionsBar from './component';
|
2024-08-08 04:57:09 +08:00
|
|
|
import {
|
|
|
|
layoutSelectOutput,
|
|
|
|
layoutSelectInput,
|
|
|
|
layoutDispatch,
|
|
|
|
} from '../layout/context';
|
2024-06-13 22:48:15 +08:00
|
|
|
import {
|
|
|
|
useIsExternalVideoEnabled,
|
|
|
|
useIsPollingEnabled,
|
|
|
|
useIsPresentationEnabled,
|
2024-06-14 21:30:48 +08:00
|
|
|
useIsTimerFeatureEnabled,
|
2024-06-13 22:48:15 +08:00
|
|
|
} from '/imports/ui/services/features';
|
|
|
|
|
2023-09-19 19:39:52 +08:00
|
|
|
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
|
2023-10-12 03:10:36 +08:00
|
|
|
import {
|
|
|
|
CURRENT_PRESENTATION_PAGE_SUBSCRIPTION,
|
|
|
|
} from '/imports/ui/components/whiteboard/queries';
|
2022-02-10 03:45:43 +08:00
|
|
|
import MediaService from '../media/service';
|
2023-11-29 21:22:59 +08:00
|
|
|
import useMeeting from '/imports/ui/core/hooks/useMeeting';
|
2023-11-30 19:08:16 +08:00
|
|
|
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
|
2024-01-20 02:40:27 +08:00
|
|
|
import { EXTERNAL_VIDEO_STOP } from '../external-video-player/mutations';
|
2024-05-01 20:39:03 +08:00
|
|
|
import { PINNED_PAD_SUBSCRIPTION } from '../notes/queries';
|
2024-06-04 21:40:54 +08:00
|
|
|
import useDeduplicatedSubscription from '../../core/hooks/useDeduplicatedSubscription';
|
2024-06-13 22:48:15 +08:00
|
|
|
import connectionStatus from '../../core/graphql/singletons/connectionStatus';
|
2024-08-29 22:47:50 +08:00
|
|
|
import { useMeetingLayoutUpdater, usePushLayoutUpdater } from '../layout/push-layout/hooks';
|
|
|
|
import useSettings from '/imports/ui/services/settings/hooks/useSettings';
|
|
|
|
import { SETTINGS } from '/imports/ui/services/settings/enums';
|
2024-09-14 01:53:14 +08:00
|
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
|
|
|
import { SMALL_VIEWPORT_BREAKPOINT } from '../layout/enums';
|
|
|
|
|
|
|
|
const isLayeredView = window.matchMedia(`(max-width: ${SMALL_VIEWPORT_BREAKPOINT}px)`);
|
2024-06-13 22:48:15 +08:00
|
|
|
|
|
|
|
const isReactionsButtonEnabled = () => {
|
|
|
|
const USER_REACTIONS_ENABLED = window.meetingClientSettings.public.userReaction.enabled;
|
|
|
|
const REACTIONS_BUTTON_ENABLED = window.meetingClientSettings.public.app.reactionsButton.enabled;
|
|
|
|
|
|
|
|
return USER_REACTIONS_ENABLED && REACTIONS_BUTTON_ENABLED;
|
|
|
|
};
|
2024-04-25 00:07:06 +08:00
|
|
|
|
2021-04-07 03:58:11 +08:00
|
|
|
const ActionsBarContainer = (props) => {
|
2024-05-29 21:26:11 +08:00
|
|
|
const NOTES_CONFIG = window.meetingClientSettings.public.notes;
|
2024-09-14 01:53:14 +08:00
|
|
|
const LAYOUT_CONFIG = window.meetingClientSettings.public.layout;
|
|
|
|
const { showPushLayoutButton } = LAYOUT_CONFIG;
|
2021-09-11 04:48:52 +08:00
|
|
|
const actionsBarStyle = layoutSelectOutput((i) => i.actionBar);
|
|
|
|
const layoutContextDispatch = layoutDispatch();
|
2024-08-29 22:47:50 +08:00
|
|
|
const cameraDockOutput = layoutSelectOutput((i) => i.cameraDock);
|
|
|
|
const cameraDockInput = layoutSelectInput((i) => i.cameraDock);
|
|
|
|
const presentationInput = layoutSelectInput((i) => i.presentation);
|
2024-09-14 01:53:14 +08:00
|
|
|
const sidebarNavigation = layoutSelectInput((i) => i.sidebarNavigation);
|
|
|
|
const sidebarContent = layoutSelectInput((i) => i.sidebarContent);
|
2021-09-10 04:49:15 +08:00
|
|
|
|
2024-06-04 21:40:54 +08:00
|
|
|
const { data: presentationPageData } = useDeduplicatedSubscription(
|
|
|
|
CURRENT_PRESENTATION_PAGE_SUBSCRIPTION,
|
|
|
|
);
|
2023-10-12 03:10:36 +08:00
|
|
|
const presentationPage = presentationPageData?.pres_page_curr[0] || {};
|
|
|
|
const isThereCurrentPresentation = !!presentationPage?.presentationId;
|
|
|
|
|
2024-08-08 04:57:09 +08:00
|
|
|
const genericMainContent = layoutSelectInput((i) => i.genericMainContent);
|
|
|
|
const isThereGenericMainContent = !!genericMainContent.genericContentId;
|
|
|
|
|
2023-11-29 21:22:59 +08:00
|
|
|
const { data: currentMeeting } = useMeeting((m) => ({
|
|
|
|
externalVideo: m.externalVideo,
|
2024-04-17 06:39:29 +08:00
|
|
|
componentsFlags: m.componentsFlags,
|
2023-11-29 21:22:59 +08:00
|
|
|
}));
|
|
|
|
|
|
|
|
const isSharingVideo = !!currentMeeting?.externalVideo?.externalVideoUrl;
|
|
|
|
|
2023-09-19 19:39:52 +08:00
|
|
|
const {
|
2023-11-29 02:31:28 +08:00
|
|
|
pluginsExtensibleAreasAggregatedState,
|
2023-09-19 19:39:52 +08:00
|
|
|
} = useContext(PluginsContext);
|
|
|
|
let actionBarItems = [];
|
2023-11-29 02:31:28 +08:00
|
|
|
if (pluginsExtensibleAreasAggregatedState.actionsBarItems) {
|
2023-09-19 19:39:52 +08:00
|
|
|
actionBarItems = [
|
2023-11-29 02:31:28 +08:00
|
|
|
...pluginsExtensibleAreasAggregatedState.actionsBarItems,
|
2023-09-19 19:39:52 +08:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-11-30 19:08:16 +08:00
|
|
|
const { data: currentUserData } = useCurrentUser((user) => ({
|
|
|
|
presenter: user.presenter,
|
2023-11-30 21:24:25 +08:00
|
|
|
isModerator: user.isModerator,
|
2023-11-30 19:08:16 +08:00
|
|
|
}));
|
2024-01-20 02:40:27 +08:00
|
|
|
|
|
|
|
const [stopExternalVideoShare] = useMutation(EXTERNAL_VIDEO_STOP);
|
2024-04-23 04:34:40 +08:00
|
|
|
|
|
|
|
const currentUser = {
|
|
|
|
userId: Auth.userID,
|
|
|
|
};
|
2023-11-30 19:08:16 +08:00
|
|
|
const amIPresenter = currentUserData?.presenter;
|
2023-11-30 21:24:25 +08:00
|
|
|
const amIModerator = currentUserData?.isModerator;
|
2024-09-11 04:10:28 +08:00
|
|
|
const [pinnedPadDataState, setPinnedPadDataState] = useState(null);
|
2021-11-24 00:04:45 +08:00
|
|
|
|
2024-09-11 04:10:28 +08:00
|
|
|
useEffect(() => {
|
|
|
|
const fetchData = async () => {
|
|
|
|
const { data: pinnedPadData } = await useDeduplicatedSubscription(
|
|
|
|
PINNED_PAD_SUBSCRIPTION,
|
|
|
|
);
|
|
|
|
setPinnedPadDataState(pinnedPadData || []);
|
|
|
|
};
|
|
|
|
|
|
|
|
fetchData();
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
const isSharedNotesPinnedFromGraphql = !!pinnedPadDataState
|
|
|
|
&& pinnedPadDataState.sharedNotes[0]?.sharedNotesExtId === NOTES_CONFIG.id;
|
2024-04-25 00:07:06 +08:00
|
|
|
|
|
|
|
const isSharedNotesPinned = isSharedNotesPinnedFromGraphql;
|
2024-06-13 22:48:15 +08:00
|
|
|
const allowExternalVideo = useIsExternalVideoEnabled();
|
|
|
|
const connected = useReactiveVar(connectionStatus.getConnectedStatusVar());
|
|
|
|
const intl = useIntl();
|
2024-06-14 21:30:48 +08:00
|
|
|
const isPresentationEnabled = useIsPresentationEnabled();
|
|
|
|
const isTimerFeatureEnabled = useIsTimerFeatureEnabled();
|
2024-06-14 22:40:49 +08:00
|
|
|
const isPollingEnabled = useIsPollingEnabled() && isPresentationEnabled;
|
2024-08-29 22:47:50 +08:00
|
|
|
const applicationSettings = useSettings(SETTINGS.APPLICATION);
|
|
|
|
const { pushLayout } = applicationSettings;
|
|
|
|
const setPushLayout = usePushLayoutUpdater(pushLayout);
|
|
|
|
const setMeetingLayout = useMeetingLayoutUpdater(
|
|
|
|
cameraDockOutput,
|
|
|
|
cameraDockInput,
|
|
|
|
presentationInput,
|
|
|
|
applicationSettings,
|
|
|
|
);
|
2024-09-14 01:53:14 +08:00
|
|
|
const { isOpen: sidebarNavigationIsOpen } = sidebarNavigation;
|
|
|
|
const { isOpen: sidebarContentIsOpen } = sidebarContent;
|
|
|
|
const ariaHidden = sidebarNavigationIsOpen
|
|
|
|
&& sidebarContentIsOpen
|
|
|
|
&& (deviceInfo.isPhone || isLayeredView.matches);
|
2022-07-30 03:02:31 +08:00
|
|
|
if (actionsBarStyle.display === false) return null;
|
2024-04-17 06:39:29 +08:00
|
|
|
if (!currentMeeting) return null;
|
2022-07-30 03:02:31 +08:00
|
|
|
|
2021-04-07 03:58:11 +08:00
|
|
|
return (
|
|
|
|
<ActionsBar {
|
|
|
|
...{
|
|
|
|
...props,
|
2024-06-13 22:48:15 +08:00
|
|
|
enableVideo: getFromUserSettings('bbb_enable_video', window.meetingClientSettings.public.kurento.enableVideo),
|
|
|
|
multiUserTools: getFromUserSettings('bbb_multi_user_tools', window.meetingClientSettings.public.whiteboard.toolbar.multiUserTools),
|
|
|
|
isReactionsButtonEnabled: isReactionsButtonEnabled(),
|
|
|
|
setPresentationIsOpen: MediaService.setPresentationIsOpen,
|
|
|
|
hasScreenshare: currentMeeting?.componentsFlags?.hasScreenshare ?? false,
|
|
|
|
isMeteorConnected: connected,
|
2024-06-24 21:09:30 +08:00
|
|
|
hasCameraAsContent: currentMeeting?.componentsFlags?.hasCameraAsContent,
|
2024-06-13 22:48:15 +08:00
|
|
|
intl,
|
|
|
|
allowExternalVideo,
|
|
|
|
isPollingEnabled,
|
2024-06-14 21:30:48 +08:00
|
|
|
isPresentationEnabled,
|
2021-04-07 03:58:11 +08:00
|
|
|
currentUser,
|
2023-11-30 21:24:25 +08:00
|
|
|
amIModerator,
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch,
|
2021-07-22 22:04:38 +08:00
|
|
|
actionsBarStyle,
|
2021-11-24 00:04:45 +08:00
|
|
|
amIPresenter,
|
2023-09-19 19:39:52 +08:00
|
|
|
actionBarItems,
|
2023-10-12 03:10:36 +08:00
|
|
|
isThereCurrentPresentation,
|
2023-11-29 21:22:59 +08:00
|
|
|
isSharingVideo,
|
2024-01-20 02:40:27 +08:00
|
|
|
stopExternalVideoShare,
|
2024-04-25 00:07:06 +08:00
|
|
|
isSharedNotesPinned,
|
2024-04-30 23:45:05 +08:00
|
|
|
isTimerActive: currentMeeting.componentsFlags.hasTimer,
|
2024-06-14 21:30:48 +08:00
|
|
|
isTimerEnabled: isTimerFeatureEnabled,
|
2024-08-08 04:57:09 +08:00
|
|
|
hasGenericContent: isThereGenericMainContent,
|
2024-08-29 22:47:50 +08:00
|
|
|
setPushLayout,
|
|
|
|
setMeetingLayout,
|
2024-09-14 01:53:14 +08:00
|
|
|
showPushLayout: showPushLayoutButton && applicationSettings.selectedLayout === 'custom',
|
|
|
|
ariaHidden,
|
2021-04-07 03:58:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-06-13 22:48:15 +08:00
|
|
|
export default ActionsBarContainer;
|