Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

functions.web.js 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* global APP, JitsiMeetJS, loggingConfig */
  2. import { isRoomValid } from '../base/conference';
  3. import { RouteRegistry } from '../base/navigator';
  4. import { Platform } from '../base/react';
  5. import { Conference } from '../conference';
  6. import { MobileBrowserPage } from '../unsupported-browser';
  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 { _getRoomAndDomainFromUrlString } 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 OS = Platform.OS;
  26. const state
  27. = typeof stateOrGetState === 'function'
  28. ? stateOrGetState()
  29. : stateOrGetState;
  30. // If mobile browser page was shown, there is no need to show it again.
  31. const { mobileBrowserPageIsShown } = state['features/unsupported-browser'];
  32. const { room } = state['features/base/conference'];
  33. const component = isRoomValid(room) ? Conference : WelcomePage;
  34. const route = RouteRegistry.getRouteByComponent(component);
  35. if ((OS === 'android' || OS === 'ios') && !mobileBrowserPageIsShown) {
  36. route.component = MobileBrowserPage;
  37. }
  38. return route;
  39. }
  40. /**
  41. * Temporary solution. Later we'll get rid of global APP and set its properties
  42. * in redux store.
  43. *
  44. * @returns {void}
  45. */
  46. export function init() {
  47. URLProcessor.setConfigParametersFromUrl();
  48. _initLogging();
  49. APP.keyboardshortcut = KeyboardShortcut;
  50. APP.tokenData = getTokenData();
  51. // Force enable the API if jwt token is passed because most probably
  52. // jitsi meet is displayed inside of wrapper that will need to communicate
  53. // with jitsi meet.
  54. APP.API.init(APP.tokenData.jwt ? { forceEnable: true } : undefined);
  55. APP.translation.init(settings.getLanguage());
  56. }
  57. /**
  58. * Adjusts the logging levels.
  59. *
  60. * @private
  61. * @returns {void}
  62. */
  63. function _configureLoggingLevels() {
  64. // NOTE The library Logger is separated from the app loggers, so the levels
  65. // have to be set in two places
  66. // Set default logging level
  67. const defaultLogLevel
  68. = loggingConfig.defaultLogLevel || JitsiMeetJS.logLevels.TRACE;
  69. Logger.setLogLevel(defaultLogLevel);
  70. JitsiMeetJS.setLogLevel(defaultLogLevel);
  71. // NOTE console was used on purpose here to go around the logging and always
  72. // print the default logging level to the console
  73. console.info(`Default logging level set to: ${defaultLogLevel}`);
  74. // Set log level for each logger
  75. if (loggingConfig) {
  76. Object.keys(loggingConfig).forEach(loggerName => {
  77. if (loggerName !== 'defaultLogLevel') {
  78. const level = loggingConfig[loggerName];
  79. Logger.setLogLevelById(level, loggerName);
  80. JitsiMeetJS.setLogLevelById(level, loggerName);
  81. }
  82. });
  83. }
  84. }
  85. /**
  86. * Initializes logging in the app.
  87. *
  88. * @private
  89. * @returns {void}
  90. */
  91. function _initLogging() {
  92. // Adjust logging level
  93. _configureLoggingLevels();
  94. // Create the LogCollector and register it as the global log transport. It
  95. // is done early to capture as much logs as possible. Captured logs will be
  96. // cached, before the JitsiMeetLogStorage gets ready (statistics module is
  97. // initialized).
  98. if (!APP.logCollector && !loggingConfig.disableLogCollector) {
  99. APP.logCollector = new Logger.LogCollector(new JitsiMeetLogStorage());
  100. Logger.addGlobalTransport(APP.logCollector);
  101. JitsiMeetJS.addGlobalLogTransport(APP.logCollector);
  102. }
  103. }