2023-02-14 09:50:46 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
2018-06-14 09:14:32 +00:00
|
|
|
|
2023-02-14 09:50:46 +00:00
|
|
|
import { IReduxState } from '../app/types';
|
2018-06-14 09:14:32 +00:00
|
|
|
|
2023-02-14 09:50:46 +00:00
|
|
|
// @ts-ignore
|
|
|
|
import PageReloadOverlay from './components/web/PageReloadOverlay';
|
|
|
|
// @ts-ignore
|
|
|
|
import SuspendedOverlay from './components/web/SuspendedOverlay';
|
|
|
|
// @ts-ignore
|
|
|
|
import UserMediaPermissionsOverlay from './components/web/UserMediaPermissionsOverlay';
|
2018-06-14 09:14:32 +00:00
|
|
|
/**
|
|
|
|
* Returns the overlay to be currently rendered.
|
|
|
|
*
|
2022-11-10 08:45:56 +00:00
|
|
|
* @param {IReduxState} state - The Redux state.
|
2018-06-14 09:14:32 +00:00
|
|
|
* @returns {?React$ComponentType<*>}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function getOverlayToRender(state: IReduxState) {
|
2023-02-14 09:50:46 +00:00
|
|
|
const overlays = [
|
|
|
|
PageReloadOverlay,
|
|
|
|
SuspendedOverlay,
|
|
|
|
UserMediaPermissionsOverlay
|
|
|
|
];
|
|
|
|
|
|
|
|
for (const overlay of overlays) {
|
2018-06-14 09:14:32 +00:00
|
|
|
// react-i18n / react-redux wrap components and thus we cannot access
|
|
|
|
// the wrapped component's static methods directly.
|
2022-11-10 08:45:56 +00:00
|
|
|
// @ts-ignore
|
2018-06-14 09:14:32 +00:00
|
|
|
const component = overlay.WrappedComponent || overlay;
|
|
|
|
|
|
|
|
if (component.needsRender(state)) {
|
|
|
|
return overlay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
}
|