bigbluebutton-Github/bigbluebutton-html5/imports/startup/client/base.jsx

108 lines
3.0 KiB
React
Raw Normal View History

2021-09-13 19:34:03 +08:00
import React, { Component } from 'react';
2017-03-11 02:33:46 +08:00
import AppContainer from '/imports/ui/components/app/container';
import Session from '/imports/ui/services/storage/in-memory';
import DebugWindow from '/imports/ui/components/debug-window/component';
import { ACTIONS } from '/imports/ui/components/layout/enums';
import useSettings from '/imports/ui/services/settings/hooks/useSettings';
import { SETTINGS } from '/imports/ui/services/settings/enums';
2024-08-30 02:48:23 +08:00
import { layoutDispatch } from '/imports/ui/components/layout/context';
const HTML = document.getElementsByTagName('html')[0];
2019-03-12 21:56:05 +08:00
const fullscreenChangedEvents = [
'fullscreenchange',
'webkitfullscreenchange',
'mozfullscreenchange',
'MSFullscreenChange',
];
2021-09-13 19:34:03 +08:00
class Base extends Component {
constructor(props) {
super(props);
2017-03-11 02:33:46 +08:00
2021-11-20 03:26:04 +08:00
this.handleFullscreenChange = this.handleFullscreenChange.bind(this);
}
2021-09-13 19:34:03 +08:00
componentDidMount() {
const { animations } = this.props;
const APP_CONFIG = window.meetingClientSettings.public.app;
const CAPTIONS_ALWAYS_VISIBLE = APP_CONFIG.audioCaptions.alwaysVisible;
if (animations) HTML.classList.add('animationsEnabled');
if (!animations) HTML.classList.add('animationsDisabled');
2019-03-12 00:21:12 +08:00
fullscreenChangedEvents.forEach((event) => {
2021-11-20 03:26:04 +08:00
document.addEventListener(event, this.handleFullscreenChange);
2019-03-12 00:21:12 +08:00
});
Session.setItem('isFullscreen', false);
Session.setItem('audioCaptions', CAPTIONS_ALWAYS_VISIBLE);
2021-09-13 19:34:03 +08:00
}
2019-03-12 00:21:12 +08:00
componentDidUpdate(prevProps) {
const { animations } = this.props;
2020-06-09 11:09:46 +08:00
const enabled = HTML.classList.contains('animationsEnabled');
const disabled = HTML.classList.contains('animationsDisabled');
2021-09-13 19:34:03 +08:00
if (animations && animations !== prevProps.animations) {
if (disabled) HTML.classList.remove('animationsDisabled');
HTML.classList.add('animationsEnabled');
2021-09-13 19:34:03 +08:00
} else if (!animations && animations !== prevProps.animations) {
if (enabled) HTML.classList.remove('animationsEnabled');
HTML.classList.add('animationsDisabled');
}
2021-09-13 19:34:03 +08:00
}
2021-09-13 19:34:03 +08:00
componentWillUnmount() {
fullscreenChangedEvents.forEach((event) => {
2021-11-20 03:26:04 +08:00
document.removeEventListener(event, this.handleFullscreenChange);
2021-09-13 19:34:03 +08:00
});
}
2017-03-11 02:33:46 +08:00
handleFullscreenChange() {
const { layoutContextDispatch } = this.props;
if (document.fullscreenElement
|| document.webkitFullscreenElement
|| document.mozFullScreenElement
|| document.msFullscreenElement) {
Session.setItem('isFullscreen', true);
} else {
layoutContextDispatch({
type: ACTIONS.SET_FULLSCREEN_ELEMENT,
value: {
element: '',
group: '',
},
});
Session.setItem('isFullscreen', false);
}
}
render() {
2021-09-13 19:34:03 +08:00
return (
<>
<DebugWindow />
<AppContainer {...this.props} />
2021-09-13 19:34:03 +08:00
</>
);
}
}
2017-03-11 02:33:46 +08:00
2021-09-13 19:34:03 +08:00
const BaseContainer = (props) => {
const { animations } = useSettings(SETTINGS.APPLICATION);
2024-08-30 02:48:23 +08:00
const layoutContextDispatch = layoutDispatch();
2024-01-30 21:03:11 +08:00
return (
<Base
{...{
animations,
2024-08-30 02:48:23 +08:00
layoutContextDispatch,
2024-01-30 21:03:11 +08:00
...props,
}}
/>
);
2021-09-13 19:34:03 +08:00
};
2024-06-12 01:18:28 +08:00
export default BaseContainer;