jiti-meet/react/index.web.js

58 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-12-14 10:32:36 +00:00
/* global APP */
import React from 'react';
import ReactDOM from 'react-dom';
import { getJitsiMeetTransport } from '../modules/transport';
import { App } from './features/app';
import { Platform } from './features/base/react';
2016-12-14 10:32:36 +00:00
const logger = require('jitsi-meet-logger').getLogger(__filename);
const OS = Platform.OS;
2016-12-14 10:32:36 +00:00
/**
* Renders the app when the DOM tree has been loaded.
2016-12-14 10:32:36 +00:00
*/
document.addEventListener('DOMContentLoaded', () => {
const now = window.performance.now();
APP.connectionTimes['document.ready'] = now;
logger.log('(TIME) document ready:\t', now);
2017-06-09 19:09:23 +00:00
// Render the main/root Component.
ReactDOM.render(<App />, document.getElementById('react'));
2016-12-14 10:32:36 +00:00
});
// Workaround for the issue when returning to a page with the back button and
// the page is loaded from the 'back-forward' cache on iOS which causes nothing
// to be rendered.
if (OS === 'ios') {
window.addEventListener('pageshow', event => {
// Detect pages loaded from the 'back-forward' cache
// (https://webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/)
if (event.persisted) {
// Maybe there is a more graceful approach but in the moment of
// writing nothing else resolves the issue. I tried to execute our
// DOMContentLoaded handler but it seems that the 'onpageshow' event
// is triggered only when 'window.location.reload()' code exists.
window.location.reload();
}
});
}
2016-12-14 10:32:36 +00:00
/**
* Stops collecting the logs and disposing the API when the user closes the
* page.
2016-12-14 10:32:36 +00:00
*/
window.addEventListener('beforeunload', () => {
// Stop the LogCollector
if (APP.logCollectorStarted) {
APP.logCollector.stop();
APP.logCollectorStarted = false;
}
APP.API.notifyConferenceLeft(APP.conference.roomName);
2016-12-14 10:32:36 +00:00
APP.API.dispose();
getJitsiMeetTransport().dispose();
2016-12-14 10:32:36 +00:00
});