bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/actions-bar/container.jsx

148 lines
5.7 KiB
React
Raw Normal View History

import React, { useContext } from 'react';
2024-06-13 22:48:15 +08:00
import { useIntl } from 'react-intl';
import { useMutation, useReactiveVar } from '@apollo/client';
import getFromUserSettings from '/imports/ui/services/users-settings';
2018-11-13 06:09:04 +08:00
import Auth from '/imports/ui/services/auth';
import ActionsBar from './component';
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';
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';
import MediaService from '../media/service';
import useMeeting from '/imports/ui/core/hooks/useMeeting';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
import { EXTERNAL_VIDEO_STOP } from '../external-video-player/mutations';
import { PINNED_PAD_SUBSCRIPTION } from '../notes/queries';
import useDeduplicatedSubscription from '../../core/hooks/useDeduplicatedSubscription';
2024-06-13 22:48:15 +08:00
import connectionStatus from '../../core/graphql/singletons/connectionStatus';
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-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;
};
const ActionsBarContainer = (props) => {
const NOTES_CONFIG = window.meetingClientSettings.public.notes;
2021-09-11 04:48:52 +08:00
const actionsBarStyle = layoutSelectOutput((i) => i.actionBar);
const layoutContextDispatch = layoutDispatch();
const cameraDockOutput = layoutSelectOutput((i) => i.cameraDock);
const cameraDockInput = layoutSelectInput((i) => i.cameraDock);
const presentationInput = layoutSelectInput((i) => i.presentation);
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;
const genericMainContent = layoutSelectInput((i) => i.genericMainContent);
const isThereGenericMainContent = !!genericMainContent.genericContentId;
const { data: currentMeeting } = useMeeting((m) => ({
externalVideo: m.externalVideo,
2024-04-17 06:39:29 +08:00
componentsFlags: m.componentsFlags,
}));
const isSharingVideo = !!currentMeeting?.externalVideo?.externalVideoUrl;
const {
pluginsExtensibleAreasAggregatedState,
} = useContext(PluginsContext);
let actionBarItems = [];
if (pluginsExtensibleAreasAggregatedState.actionsBarItems) {
actionBarItems = [
...pluginsExtensibleAreasAggregatedState.actionsBarItems,
];
}
const { data: currentUserData } = useCurrentUser((user) => ({
presenter: user.presenter,
isModerator: user.isModerator,
}));
const [stopExternalVideoShare] = useMutation(EXTERNAL_VIDEO_STOP);
2024-04-23 04:34:40 +08:00
const currentUser = {
userId: Auth.userID,
};
const amIPresenter = currentUserData?.presenter;
const amIModerator = currentUserData?.isModerator;
2021-11-24 00:04:45 +08:00
const { data: pinnedPadData } = useDeduplicatedSubscription(PINNED_PAD_SUBSCRIPTION);
const isSharedNotesPinnedFromGraphql = !!pinnedPadData
&& pinnedPadData.sharedNotes[0]?.sharedNotesExtId === NOTES_CONFIG.id;
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();
const isPollingEnabled = useIsPollingEnabled() && isPresentationEnabled;
const applicationSettings = useSettings(SETTINGS.APPLICATION);
const { pushLayout } = applicationSettings;
const setPushLayout = usePushLayoutUpdater(pushLayout);
const setMeetingLayout = useMeetingLayoutUpdater(
cameraDockOutput,
cameraDockInput,
presentationInput,
applicationSettings,
);
if (actionsBarStyle.display === false) return null;
2024-04-17 06:39:29 +08:00
if (!currentMeeting) return null;
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,
hasCameraAsContent: currentMeeting?.componentsFlags?.hasCameraAsContent,
2024-06-13 22:48:15 +08:00
intl,
allowExternalVideo,
isPollingEnabled,
2024-06-14 21:30:48 +08:00
isPresentationEnabled,
currentUser,
amIModerator,
2021-08-05 19:03:24 +08:00
layoutContextDispatch,
actionsBarStyle,
2021-11-24 00:04:45 +08:00
amIPresenter,
actionBarItems,
2023-10-12 03:10:36 +08:00
isThereCurrentPresentation,
isSharingVideo,
stopExternalVideoShare,
isSharedNotesPinned,
2024-04-30 23:45:05 +08:00
isTimerActive: currentMeeting.componentsFlags.hasTimer,
2024-06-14 21:30:48 +08:00
isTimerEnabled: isTimerFeatureEnabled,
hasGenericContent: isThereGenericMainContent,
setPushLayout,
setMeetingLayout,
}
}
/>
);
};
2024-06-13 22:48:15 +08:00
export default ActionsBarContainer;