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

100 lines
4.2 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';
2023-10-12 03:10:36 +08:00
import { useSubscription } 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 { UsersContext } from '../components-data/users-context/context';
import ActionsBar from './component';
import Service from './service';
import UserListService from '/imports/ui/components/user-list/service';
import ExternalVideoService from '/imports/ui/components/external-video-player/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';
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 usingUsersContext = useContext(UsersContext);
const {
pluginsProvidedAggregatedState,
} = useContext(PluginsContext);
let actionBarItems = [];
2023-09-19 21:09:59 +08:00
if (pluginsProvidedAggregatedState.actionsBarItems) {
actionBarItems = [
2023-09-19 21:09:59 +08:00
...pluginsProvidedAggregatedState.actionsBarItems,
];
}
const { users } = usingUsersContext;
2021-04-20 03:27:35 +08:00
const currentUser = { userId: Auth.userID, emoji: users[Auth.meetingID][Auth.userID].emoji };
2021-11-24 00:04:45 +08:00
const amIPresenter = users[Auth.meetingID][Auth.userID].presenter;
if (actionsBarStyle.display === false) return null;
return (
<ActionsBar {
...{
...props,
currentUser,
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,
}
}
/>
);
};
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(() => ({
amIModerator: Service.amIModerator(),
2019-09-05 02:32:58 +08:00
stopExternalVideoShare: ExternalVideoService.stopWatching,
enableVideo: getFromUserSettings('bbb_enable_video', Meteor.settings.public.kurento.enableVideo),
setPresentationIsOpen: MediaService.setPresentationIsOpen,
2019-09-05 02:32:58 +08:00
handleTakePresenter: Service.takePresenterRole,
isSharingVideo: Service.isSharingVideo(),
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(),
setEmojiStatus: UserListService.setEmojiStatus,
2019-09-05 02:32:58 +08:00
}))(injectIntl(ActionsBarContainer));