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.9KB

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