You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // @flow
  2. import {
  3. PageReloadFilmstripOnlyOverlay,
  4. PageReloadOverlay,
  5. SuspendedFilmstripOnlyOverlay,
  6. SuspendedOverlay,
  7. UserMediaPermissionsFilmstripOnlyOverlay,
  8. UserMediaPermissionsOverlay
  9. } from './components';
  10. declare var interfaceConfig: Object;
  11. /**
  12. * Returns the list of available overlays that might be rendered.
  13. *
  14. * @private
  15. * @returns {Array<?React$ComponentType<*>>}
  16. */
  17. function _getOverlays() {
  18. const filmstripOnly
  19. = typeof interfaceConfig === 'object' && interfaceConfig.filmStripOnly;
  20. let overlays;
  21. if (filmstripOnly) {
  22. overlays = [
  23. PageReloadFilmstripOnlyOverlay,
  24. SuspendedFilmstripOnlyOverlay,
  25. UserMediaPermissionsFilmstripOnlyOverlay
  26. ];
  27. } else {
  28. overlays = [
  29. PageReloadOverlay
  30. ];
  31. }
  32. // Mobile only has a PageReloadOverlay.
  33. if (navigator.product !== 'ReactNative') {
  34. overlays.push(...[
  35. SuspendedOverlay,
  36. UserMediaPermissionsOverlay
  37. ]);
  38. }
  39. return overlays;
  40. }
  41. /**
  42. * Returns the overlay to be currently rendered.
  43. *
  44. * @param {Object} state - The Redux state.
  45. * @returns {?React$ComponentType<*>}
  46. */
  47. export function getOverlayToRender(state: Object) {
  48. for (const overlay of _getOverlays()) {
  49. // react-i18n / react-redux wrap components and thus we cannot access
  50. // the wrapped component's static methods directly.
  51. const component = overlay.WrappedComponent || overlay;
  52. if (component.needsRender(state)) {
  53. return overlay;
  54. }
  55. }
  56. return undefined;
  57. }