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';
|
2024-06-06 21:50:03 +08:00
|
|
|
import Session from '/imports/ui/services/storage/in-memory';
|
2021-04-27 07:04:34 +08:00
|
|
|
import DebugWindow from '/imports/ui/components/debug-window/component';
|
2024-08-30 02:08:24 +08:00
|
|
|
import { ACTIONS } from '/imports/ui/components/layout/enums';
|
2024-05-18 04:33:52 +08:00
|
|
|
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';
|
2020-01-30 05:40:00 +08:00
|
|
|
|
2019-04-11 23:04:10 +08:00
|
|
|
const HTML = document.getElementsByTagName('html')[0];
|
2018-08-06 20:05:07 +08:00
|
|
|
|
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() {
|
2024-08-30 02:08:24 +08:00
|
|
|
const { animations } = this.props;
|
2024-08-28 20:59:22 +08:00
|
|
|
const APP_CONFIG = window.meetingClientSettings.public.app;
|
|
|
|
const CAPTIONS_ALWAYS_VISIBLE = APP_CONFIG.audioCaptions.alwaysVisible;
|
2021-09-16 20:25:51 +08:00
|
|
|
|
2019-04-11 23:04:10 +08:00
|
|
|
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
|
|
|
});
|
2024-06-06 21:50:03 +08:00
|
|
|
Session.setItem('isFullscreen', false);
|
2024-06-13 00:06:07 +08:00
|
|
|
Session.setItem('audioCaptions', CAPTIONS_ALWAYS_VISIBLE);
|
2021-09-13 19:34:03 +08:00
|
|
|
}
|
2019-03-12 00:21:12 +08:00
|
|
|
|
2024-03-13 22:11:58 +08:00
|
|
|
componentDidUpdate(prevProps) {
|
2024-08-30 02:08:24 +08:00
|
|
|
const { animations } = this.props;
|
2020-06-09 11:09:46 +08:00
|
|
|
|
2019-04-11 23:04:10 +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) {
|
2019-04-11 23:04:10 +08:00
|
|
|
if (disabled) HTML.classList.remove('animationsDisabled');
|
|
|
|
HTML.classList.add('animationsEnabled');
|
2021-09-13 19:34:03 +08:00
|
|
|
} else if (!animations && animations !== prevProps.animations) {
|
2019-04-11 23:04:10 +08:00
|
|
|
if (enabled) HTML.classList.remove('animationsEnabled');
|
|
|
|
HTML.classList.add('animationsDisabled');
|
2019-01-25 00:16:23 +08:00
|
|
|
}
|
2021-09-13 19:34:03 +08:00
|
|
|
}
|
2019-01-22 03:28:37 +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
|
|
|
|
2024-08-28 20:59:22 +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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-13 22:11:58 +08:00
|
|
|
render() {
|
2021-09-13 19:34:03 +08:00
|
|
|
return (
|
|
|
|
<>
|
2024-03-13 22:11:58 +08:00
|
|
|
<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) => {
|
2024-08-30 02:08:24 +08:00
|
|
|
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
|
|
|
|
{...{
|
2024-05-18 04:33:52 +08:00
|
|
|
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;
|