jiti-meet/react/features/overlay/functions.web.ts

37 lines
1.0 KiB
TypeScript
Raw Normal View History

/* eslint-disable lines-around-comment */
2018-06-14 09:14:32 +00:00
import { IReduxState } from '../app/types';
2018-06-14 09:14:32 +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.
*
* @param {IReduxState} state - The Redux state.
2018-06-14 09:14:32 +00:00
* @returns {?React$ComponentType<*>}
*/
export function getOverlayToRender(state: IReduxState) {
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.
// @ts-ignore
2018-06-14 09:14:32 +00:00
const component = overlay.WrappedComponent || overlay;
if (component.needsRender(state)) {
return overlay;
}
}
return undefined;
}