Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

functions.web.ts 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* eslint-disable lines-around-comment */
  2. import { IReduxState } from '../app/types';
  3. // @ts-ignore
  4. import PageReloadOverlay from './components/web/PageReloadOverlay';
  5. // @ts-ignore
  6. import SuspendedOverlay from './components/web/SuspendedOverlay';
  7. // @ts-ignore
  8. import UserMediaPermissionsOverlay from './components/web/UserMediaPermissionsOverlay';
  9. /**
  10. * Returns the overlay to be currently rendered.
  11. *
  12. * @param {IReduxState} state - The Redux state.
  13. * @returns {?React$ComponentType<*>}
  14. */
  15. export function getOverlayToRender(state: IReduxState) {
  16. const overlays = [
  17. PageReloadOverlay,
  18. SuspendedOverlay,
  19. UserMediaPermissionsOverlay
  20. ];
  21. for (const overlay of overlays) {
  22. // react-i18n / react-redux wrap components and thus we cannot access
  23. // the wrapped component's static methods directly.
  24. // @ts-ignore
  25. const component = overlay.WrappedComponent || overlay;
  26. if (component.needsRender(state)) {
  27. return overlay;
  28. }
  29. }
  30. return undefined;
  31. }