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

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