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

108 lines
4.3 KiB
React
Raw Normal View History

import React, { useContext } from 'react';
import { Meteor } from 'meteor/meteor';
import { withTracker } from 'meteor/react-meteor-data';
2019-02-22 05:01:39 +08:00
import { injectIntl } from 'react-intl';
import { useSubscription, useMutation } 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 Service from './service';
import CaptionsService from '/imports/ui/components/captions/service';
2023-05-11 04:03:20 +08:00
import TimerService from '/imports/ui/components/timer/service';
2021-09-11 04:48:52 +08:00
import { layoutSelectOutput, layoutDispatch } from '../layout/context';
2023-02-24 23:52:01 +08:00
import { isExternalVideoEnabled, isPollingEnabled, isPresentationEnabled } from '/imports/ui/services/features';
import { isScreenBroadcasting, isCameraAsContentBroadcasting } from '/imports/ui/components/screenshare/service';
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';
const ActionsBarContainer = (props) => {
2021-09-11 04:48:52 +08:00
const actionsBarStyle = layoutSelectOutput((i) => i.actionBar);
const layoutContextDispatch = layoutDispatch();
2023-10-12 03:10:36 +08:00
const { data: presentationPageData } = useSubscription(CURRENT_PRESENTATION_PAGE_SUBSCRIPTION);
const presentationPage = presentationPageData?.pres_page_curr[0] || {};
const isThereCurrentPresentation = !!presentationPage?.presentationId;
const { data: currentMeeting } = useMeeting((m) => ({
externalVideo: m.externalVideo,
}));
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,
emoji: user.emoji,
isModerator: user.isModerator,
}));
const [stopExternalVideoShare] = useMutation(EXTERNAL_VIDEO_STOP);
const currentUser = { userId: Auth.userID, emoji: currentUserData?.emoji };
const amIPresenter = currentUserData?.presenter;
const amIModerator = currentUserData?.isModerator;
2021-11-24 00:04:45 +08:00
if (actionsBarStyle.display === false) return null;
return (
<ActionsBar {
...{
...props,
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,
}
}
/>
);
};
2021-03-20 02:52:03 +08:00
const SELECT_RANDOM_USER_ENABLED = Meteor.settings.public.selectRandomUser.enabled;
const RAISE_HAND_BUTTON_ENABLED = Meteor.settings.public.app.raiseHandActionButton.enabled;
const RAISE_HAND_BUTTON_CENTERED = Meteor.settings.public.app.raiseHandActionButton.centered;
2016-04-29 03:02:51 +08:00
2023-07-18 19:54:36 +08:00
const isReactionsButtonEnabled = () => {
const USER_REACTIONS_ENABLED = Meteor.settings.public.userReaction.enabled;
2023-07-18 19:54:36 +08:00
const REACTIONS_BUTTON_ENABLED = Meteor.settings.public.app.reactionsButton.enabled;
return USER_REACTIONS_ENABLED && REACTIONS_BUTTON_ENABLED;
};
2016-04-29 03:02:51 +08:00
2019-09-05 02:32:58 +08:00
export default withTracker(() => ({
enableVideo: getFromUserSettings('bbb_enable_video', Meteor.settings.public.kurento.enableVideo),
setPresentationIsOpen: MediaService.setPresentationIsOpen,
isSharedNotesPinned: Service.isSharedNotesPinned(),
hasScreenshare: isScreenBroadcasting(),
hasCameraAsContent: isCameraAsContentBroadcasting(),
2019-09-05 02:32:58 +08:00
isCaptionsAvailable: CaptionsService.isCaptionsAvailable(),
2023-05-11 04:03:20 +08:00
isTimerActive: TimerService.isActive(),
isTimerEnabled: TimerService.isEnabled(),
2019-09-05 02:32:58 +08:00
isMeteorConnected: Meteor.status().connected,
2023-02-24 23:52:01 +08:00
isPollingEnabled: isPollingEnabled() && isPresentationEnabled(),
2021-03-20 02:52:03 +08:00
isSelectRandomUserEnabled: SELECT_RANDOM_USER_ENABLED,
isRaiseHandButtonEnabled: RAISE_HAND_BUTTON_ENABLED,
isRaiseHandButtonCentered: RAISE_HAND_BUTTON_CENTERED,
2023-07-18 19:54:36 +08:00
isReactionsButtonEnabled: isReactionsButtonEnabled(),
allowExternalVideo: isExternalVideoEnabled(),
2019-09-05 02:32:58 +08:00
}))(injectIntl(ActionsBarContainer));