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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* global APP */
  2. import React from 'react';
  3. import ReactDOM from 'react-dom';
  4. import { compose, createStore } from 'redux';
  5. import Thunk from 'redux-thunk';
  6. import config from './config';
  7. import { App } from './features/app';
  8. import { MiddlewareRegistry, ReducerRegistry } from './features/base/redux';
  9. const logger = require('jitsi-meet-logger').getLogger(__filename);
  10. // Create combined reducer from all reducers in registry.
  11. const reducer = ReducerRegistry.combineReducers();
  12. // Apply all registered middleware from the MiddlewareRegistry + additional
  13. // 3rd party middleware:
  14. // - Thunk - allows us to dispatch async actions easily. For more info
  15. // @see https://github.com/gaearon/redux-thunk.
  16. let middleware = MiddlewareRegistry.applyMiddleware(Thunk);
  17. // Try to enable Redux DevTools Chrome extension in order to make it available
  18. // for the purposes of facilitating development.
  19. let devToolsExtension;
  20. if (typeof window === 'object'
  21. && (devToolsExtension = window.devToolsExtension)) {
  22. middleware = compose(middleware, devToolsExtension());
  23. }
  24. // Create Redux store with our reducer and middleware.
  25. const store = createStore(reducer, middleware);
  26. /**
  27. * Renders the app when the DOM tree has been loaded.
  28. */
  29. document.addEventListener('DOMContentLoaded', () => {
  30. const now = window.performance.now();
  31. APP.connectionTimes['document.ready'] = now;
  32. logger.log('(TIME) document ready:\t', now);
  33. // Render the main Component.
  34. ReactDOM.render(
  35. <App
  36. config = { config }
  37. store = { store } />,
  38. document.getElementById('react'));
  39. });
  40. /**
  41. * Stops collecting the logs and disposing the API when the user closes the
  42. * page.
  43. */
  44. window.addEventListener('beforeunload', () => {
  45. // Stop the LogCollector
  46. if (APP.logCollectorStarted) {
  47. APP.logCollector.stop();
  48. APP.logCollectorStarted = false;
  49. }
  50. APP.API.dispose();
  51. });