bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/app/container.jsx

144 lines
5.1 KiB
React
Raw Normal View History

import React, { useEffect } from 'react';
2024-01-30 00:27:30 +08:00
import AudioCaptionsLiveContainer from '/imports/ui/components/audio/audio-graphql/audio-captions/live/component';
import getFromUserSettings from '/imports/ui/services/users-settings';
import deviceInfo from '/imports/utils/deviceInfo';
import { useIsPresentationEnabled, useIsExternalVideoEnabled } from '/imports/ui/services/features';
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
import useMeeting from '/imports/ui/core/hooks/useMeeting';
import {
layoutSelectInput,
layoutSelectOutput,
2021-09-11 04:48:52 +08:00
} from '../layout/context';
import useSetSpeechOptions from '../audio/audio-graphql/hooks/useSetSpeechOptions';
2019-04-11 03:40:40 +08:00
import App from './component';
import { PINNED_PAD_SUBSCRIPTION } from '../notes/queries';
import useDeduplicatedSubscription from '../../core/hooks/useDeduplicatedSubscription';
import useSettings from '../../services/settings/hooks/useSettings';
import { SETTINGS } from '../../services/settings/enums';
2017-07-14 22:18:07 +08:00
const AppContainer = (props) => {
2024-06-12 05:55:38 +08:00
const {
viewScreenshare,
} = useSettings(SETTINGS.DATA_SAVING);
const {
data: currentUser,
} = useCurrentUser((u) => ({
away: u.away,
raiseHand: u.raiseHand,
userId: u.userId,
presenter: u.presenter,
speechLocale: u.speechLocale,
2024-06-12 05:55:38 +08:00
}));
const {
data: currentMeeting,
} = useMeeting((m) => ({
layout: m.layout,
componentsFlags: m.componentsFlags,
}));
2024-06-13 22:48:15 +08:00
const presentationRestoreOnUpdate = getFromUserSettings(
'bbb_force_restore_presentation_on_new_events',
window.meetingClientSettings.public.presentation.restoreOnUpdate,
);
2024-06-12 05:55:38 +08:00
const NOTES_CONFIG = window.meetingClientSettings.public.notes;
const {
selectedLayout,
darkTheme,
} = useSettings(SETTINGS.APPLICATION);
const { partialUtterances, minUtteranceLength } = useSettings(SETTINGS.TRANSCRIPTION);
2021-09-11 04:48:52 +08:00
const sidebarContent = layoutSelectInput((i) => i.sidebarContent);
const genericMainContent = layoutSelectInput((i) => i.genericMainContent);
2021-09-11 04:48:52 +08:00
const sidebarNavigation = layoutSelectInput((i) => i.sidebarNavigation);
const actionsBarStyle = layoutSelectOutput((i) => i.actionBar);
const captionsStyle = layoutSelectOutput((i) => i.captions);
const presentation = layoutSelectInput((i) => i.presentation);
const sharedNotesInput = layoutSelectInput((i) => i.sharedNotes);
const setSpeechOptions = useSetSpeechOptions();
const { data: pinnedPadData } = useDeduplicatedSubscription(PINNED_PAD_SUBSCRIPTION);
const isSharedNotesPinnedFromGraphql = !!pinnedPadData
&& pinnedPadData.sharedNotes[0]?.sharedNotesExtId === NOTES_CONFIG.id;
const isSharedNotesPinned = sharedNotesInput?.isPinned && isSharedNotesPinnedFromGraphql;
2024-06-14 21:30:48 +08:00
const isExternalVideoEnabled = useIsExternalVideoEnabled();
const isPresentationEnabled = useIsPresentationEnabled();
const isPresenter = currentUser?.presenter;
const { isOpen: sidebarContentIsOpen } = sidebarContent;
const { isOpen: sidebarNavigationIsOpen } = sidebarNavigation;
const { isOpen } = presentation;
const presentationIsOpen = isOpen;
const isSharingVideo = currentMeeting?.componentsFlags.hasExternalVideo;
2024-06-14 21:30:48 +08:00
const shouldShowExternalVideo = isExternalVideoEnabled && isSharingVideo;
const shouldShowGenericMainContent = !!genericMainContent.genericContentId;
2024-06-13 22:48:15 +08:00
const shouldShowScreenshare = (viewScreenshare || isPresenter)
2024-06-25 00:02:10 +08:00
&& (currentMeeting?.componentsFlags?.hasScreenshare
|| currentMeeting?.componentsFlags?.hasCameraAsContent);
const shouldShowPresentation = (!shouldShowScreenshare && !isSharedNotesPinned
&& !shouldShowExternalVideo && !shouldShowGenericMainContent
2024-06-14 21:30:48 +08:00
&& (presentationIsOpen || presentationRestoreOnUpdate)) && isPresentationEnabled;
2024-04-17 06:39:29 +08:00
2024-06-14 22:12:44 +08:00
useEffect(() => {
setSpeechOptions(
partialUtterances,
minUtteranceLength,
);
}, [partialUtterances, minUtteranceLength]);
// Update after editing app savings
useEffect(() => {
setSpeechOptions(
partialUtterances,
minUtteranceLength,
);
}, [partialUtterances, minUtteranceLength]);
2024-06-12 05:55:38 +08:00
const customStyleUrl = getFromUserSettings('bbb_custom_style_url', false)
|| window.meetingClientSettings.public.app.customStyleUrl;
if (!currentUser) return null;
2024-06-14 22:12:44 +08:00
2024-06-12 05:55:38 +08:00
return currentUser?.userId
2021-07-21 21:19:47 +08:00
? (
<App
{...{
2024-06-12 05:55:38 +08:00
hideActionsBar: getFromUserSettings('bbb_hide_actions_bar', false),
customStyle: getFromUserSettings('bbb_custom_style', false),
isPhone: deviceInfo.isPhone,
currentUserAway: currentUser.away,
currentUserRaiseHand: currentUser.raiseHand,
customStyleUrl,
2021-07-21 21:19:47 +08:00
actionsBarStyle,
captionsStyle,
selectedLayout,
presentationIsOpen,
2021-07-21 21:19:47 +08:00
sidebarNavigationIsOpen,
sidebarContentIsOpen,
shouldShowExternalVideo,
isPresenter,
speechLocale: currentUser?.speechLocale,
shouldShowScreenshare,
isSharedNotesPinned,
shouldShowPresentation,
genericMainContentId: genericMainContent.genericContentId,
audioCaptions: <AudioCaptionsLiveContainer />,
darkTheme,
2024-06-15 02:40:40 +08:00
isPresentationEnabled,
2021-07-21 21:19:47 +08:00
}}
{...props}
2021-07-21 21:19:47 +08:00
/>
)
: null;
2017-07-14 22:18:07 +08:00
};
2024-06-12 05:55:38 +08:00
export default AppContainer;