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.web.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* global APP, JitsiMeetJS, loggingConfig */
  2. import { isRoomValid } from '../base/conference';
  3. import { RouteRegistry } from '../base/react';
  4. import { interceptComponent } from '../base/util';
  5. import { Conference } from '../conference';
  6. import { WelcomePage } from '../welcome';
  7. import URLProcessor from '../../../modules/config/URLProcessor';
  8. import KeyboardShortcut
  9. from '../../../modules/keyboardshortcut/keyboardshortcut';
  10. import settings from '../../../modules/settings/Settings';
  11. import getTokenData from '../../../modules/tokendata/TokenData';
  12. import JitsiMeetLogStorage from '../../../modules/util/JitsiMeetLogStorage';
  13. const Logger = require('jitsi-meet-logger');
  14. export { _parseURIString } from './functions.native';
  15. /**
  16. * Determines which route is to be rendered in order to depict a specific Redux
  17. * store.
  18. *
  19. * @param {(Object|Function)} stateOrGetState - Redux state or Regux getState()
  20. * method.
  21. * @returns {Route}
  22. */
  23. export function _getRouteToRender(stateOrGetState) {
  24. const state
  25. = typeof stateOrGetState === 'function'
  26. ? stateOrGetState()
  27. : stateOrGetState;
  28. // If mobile browser page was shown, there is no need to show it again.
  29. const { room } = state['features/base/conference'];
  30. const component = isRoomValid(room) ? Conference : WelcomePage;
  31. const route = RouteRegistry.getRouteByComponent(component);
  32. // Intercepts route components if any of component interceptor rules
  33. // is satisfied.
  34. route.component = interceptComponent(state, component);
  35. return route;
  36. }
  37. /**
  38. * Temporary solution. Later we'll get rid of global APP and set its properties
  39. * in redux store.
  40. *
  41. * @returns {void}
  42. */
  43. export function init() {
  44. URLProcessor.setConfigParametersFromUrl();
  45. _initLogging();
  46. APP.keyboardshortcut = KeyboardShortcut;
  47. APP.tokenData = getTokenData();
  48. // Force enable the API if jwt token is passed because most probably
  49. // jitsi meet is displayed inside of wrapper that will need to communicate
  50. // with jitsi meet.
  51. APP.API.init(APP.tokenData.jwt ? { forceEnable: true } : undefined);
  52. APP.translation.init(settings.getLanguage());
  53. }
  54. /**
  55. * Adjusts the logging levels.
  56. *
  57. * @private
  58. * @returns {void}
  59. */
  60. function _configureLoggingLevels() {
  61. // NOTE The library Logger is separated from the app loggers, so the levels
  62. // have to be set in two places
  63. // Set default logging level
  64. const defaultLogLevel
  65. = loggingConfig.defaultLogLevel || JitsiMeetJS.logLevels.TRACE;
  66. Logger.setLogLevel(defaultLogLevel);
  67. JitsiMeetJS.setLogLevel(defaultLogLevel);
  68. // NOTE console was used on purpose here to go around the logging and always
  69. // print the default logging level to the console
  70. console.info(`Default logging level set to: ${defaultLogLevel}`);
  71. // Set log level for each logger
  72. if (loggingConfig) {
  73. Object.keys(loggingConfig).forEach(loggerName => {
  74. if (loggerName !== 'defaultLogLevel') {
  75. const level = loggingConfig[loggerName];
  76. Logger.setLogLevelById(level, loggerName);
  77. JitsiMeetJS.setLogLevelById(level, loggerName);
  78. }
  79. });
  80. }
  81. }
  82. /**
  83. * Initializes logging in the app.
  84. *
  85. * @private
  86. * @returns {void}
  87. */
  88. function _initLogging() {
  89. // Adjust logging level
  90. _configureLoggingLevels();
  91. // Create the LogCollector and register it as the global log transport. It
  92. // is done early to capture as much logs as possible. Captured logs will be
  93. // cached, before the JitsiMeetLogStorage gets ready (statistics module is
  94. // initialized).
  95. if (!APP.logCollector && !loggingConfig.disableLogCollector) {
  96. APP.logCollector = new Logger.LogCollector(new JitsiMeetLogStorage());
  97. Logger.addGlobalTransport(APP.logCollector);
  98. JitsiMeetJS.addGlobalLogTransport(APP.logCollector);
  99. }
  100. }