Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

functions.web.js 3.9KB

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