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.

index.web.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* global APP */
  2. import React from 'react';
  3. import ReactDOM from 'react-dom';
  4. import { App } from './features/app/components';
  5. import { getLogger } from './features/base/logging/functions';
  6. import { Platform } from './features/base/react';
  7. import { getJitsiMeetGlobalNS } from './features/base/util';
  8. import PrejoinApp from './features/prejoin/components/PrejoinApp';
  9. const logger = getLogger('index.web');
  10. const OS = Platform.OS;
  11. /**
  12. * Renders the app when the DOM tree has been loaded.
  13. */
  14. document.addEventListener('DOMContentLoaded', () => {
  15. const now = window.performance.now();
  16. APP.connectionTimes['document.ready'] = now;
  17. logger.log('(TIME) document ready:\t', now);
  18. });
  19. // Workaround for the issue when returning to a page with the back button and
  20. // the page is loaded from the 'back-forward' cache on iOS which causes nothing
  21. // to be rendered.
  22. if (OS === 'ios') {
  23. window.addEventListener('pageshow', event => {
  24. // Detect pages loaded from the 'back-forward' cache
  25. // (https://webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/)
  26. if (event.persisted) {
  27. // Maybe there is a more graceful approach but in the moment of
  28. // writing nothing else resolves the issue. I tried to execute our
  29. // DOMContentLoaded handler but it seems that the 'onpageshow' event
  30. // is triggered only when 'window.location.reload()' code exists.
  31. window.location.reload();
  32. }
  33. });
  34. }
  35. const globalNS = getJitsiMeetGlobalNS();
  36. globalNS.entryPoints = {
  37. APP: App,
  38. PREJOIN: PrejoinApp
  39. };
  40. globalNS.renderEntryPoint = ({
  41. Component,
  42. props = {},
  43. elementId = 'react'
  44. }) => {
  45. ReactDOM.render(
  46. <Component { ...props } />,
  47. document.getElementById(elementId)
  48. );
  49. };