Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. const { room } = state['features/base/conference'];
  33. const component = isRoomValid(room) ? Conference : WelcomePage;
  34. // We're using spread operator here to create copy of the route registered
  35. // in registry. If we overwrite some of its properties (like 'component')
  36. // they will stay unchanged in the registry.
  37. const route = { ...RouteRegistry.getRouteByComponent(component) };
  38. if ((OS === 'android' || OS === 'ios') && !landingIsShown) {
  39. route.component = Landing;
  40. }
  41. return route;
  42. }
  43. /**
  44. * Method checking whether route objects are equal by value. Returns true if
  45. * and only if key values of the first object are equal to key values of
  46. * the second one.
  47. *
  48. * @param {Object} newRoute - New route object to be compared.
  49. * @param {Object} oldRoute - Old route object to be compared.
  50. * @returns {boolean}
  51. */
  52. export function areRoutesEqual(newRoute, oldRoute) {
  53. return Object.keys(newRoute)
  54. .every(key => newRoute[key] === oldRoute[key]);
  55. }
  56. /**
  57. * Temporary solution. Later we'll get rid of global APP and set its properties
  58. * in redux store.
  59. *
  60. * @returns {void}
  61. */
  62. export function init() {
  63. URLProcessor.setConfigParametersFromUrl();
  64. _initLogging();
  65. APP.keyboardshortcut = KeyboardShortcut;
  66. APP.tokenData = getTokenData();
  67. // Force enable the API if jwt token is passed because most probably
  68. // jitsi meet is displayed inside of wrapper that will need to communicate
  69. // with jitsi meet.
  70. APP.API.init(APP.tokenData.jwt ? { forceEnable: true } : undefined);
  71. APP.translation.init(settings.getLanguage());
  72. }
  73. /**
  74. * Adjusts the logging levels.
  75. *
  76. * @private
  77. * @returns {void}
  78. */
  79. function _configureLoggingLevels() {
  80. // NOTE The library Logger is separated from the app loggers, so the levels
  81. // have to be set in two places
  82. // Set default logging level
  83. const defaultLogLevel
  84. = loggingConfig.defaultLogLevel || JitsiMeetJS.logLevels.TRACE;
  85. Logger.setLogLevel(defaultLogLevel);
  86. JitsiMeetJS.setLogLevel(defaultLogLevel);
  87. // NOTE console was used on purpose here to go around the logging and always
  88. // print the default logging level to the console
  89. console.info(`Default logging level set to: ${defaultLogLevel}`);
  90. // Set log level for each logger
  91. if (loggingConfig) {
  92. Object.keys(loggingConfig).forEach(loggerName => {
  93. if (loggerName !== 'defaultLogLevel') {
  94. const level = loggingConfig[loggerName];
  95. Logger.setLogLevelById(level, loggerName);
  96. JitsiMeetJS.setLogLevelById(level, loggerName);
  97. }
  98. });
  99. }
  100. }
  101. /**
  102. * Initializes logging in the app.
  103. *
  104. * @private
  105. * @returns {void}
  106. */
  107. function _initLogging() {
  108. // Adjust logging level
  109. _configureLoggingLevels();
  110. // Create the LogCollector and register it as the global log transport. It
  111. // is done early to capture as much logs as possible. Captured logs will be
  112. // cached, before the JitsiMeetLogStorage gets ready (statistics module is
  113. // initialized).
  114. if (!APP.logCollector && !loggingConfig.disableLogCollector) {
  115. APP.logCollector = new Logger.LogCollector(new JitsiMeetLogStorage());
  116. Logger.addGlobalTransport(APP.logCollector);
  117. JitsiMeetJS.addGlobalLogTransport(APP.logCollector);
  118. }
  119. }