您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.web.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import { getName } from '../app/functions.web';
  2. import { isSuboptimalBrowser } from '../base/environment';
  3. import { translateToHTML } from '../base/i18n';
  4. import { getLocalParticipant } from '../base/participants';
  5. import { toState } from '../base/redux';
  6. import { getBackendSafePath, getJitsiMeetGlobalNS } from '../base/util';
  7. import { showWarningNotification } from '../notifications';
  8. import { createRnnoiseProcessor } from '../stream-effects/rnnoise';
  9. export * from './functions.any';
  10. /**
  11. * Returns the result of getWiFiStats from the global NS or does nothing
  12. (returns empty result).
  13. * Fixes a concurrency problem where we need to pass a function when creating
  14. * a JitsiConference, but that method is added to the context later.
  15. *
  16. * @returns {Promise}
  17. * @private
  18. */
  19. const getWiFiStatsMethod = () => {
  20. const gloabalNS = getJitsiMeetGlobalNS();
  21. return gloabalNS.getWiFiStats ? gloabalNS.getWiFiStats() : Promise.resolve('{}');
  22. };
  23. /**
  24. * Shows the suboptimal experience notification if needed.
  25. *
  26. * @param {Function} dispatch - The dispatch method.
  27. * @param {Function} t - The translation function.
  28. * @returns {void}
  29. */
  30. export function maybeShowSuboptimalExperienceNotification(dispatch, t) {
  31. if (isSuboptimalBrowser()) {
  32. dispatch(
  33. showWarningNotification(
  34. {
  35. titleKey: 'notify.suboptimalExperienceTitle',
  36. description: translateToHTML(
  37. t,
  38. 'notify.suboptimalBrowserWarning',
  39. {
  40. recommendedBrowserPageLink: `${window.location.origin}/static/recommendedBrowsers.html`
  41. }
  42. )
  43. }
  44. )
  45. );
  46. }
  47. }
  48. /**
  49. * Returns an object aggregating the conference options.
  50. *
  51. * @param {Object|Function} stateful - The redux store state.
  52. * @returns {Object} - Options object.
  53. */
  54. export function getConferenceOptions(stateful) {
  55. const state = toState(stateful);
  56. const options = state['features/base/config'];
  57. const { locationURL } = state['features/base/connection'];
  58. const { tenant } = state['features/base/jwt'];
  59. const { email, name: nick } = getLocalParticipant(state);
  60. if (tenant) {
  61. options.siteID = tenant;
  62. }
  63. if (options.enableDisplayNameInStats && nick) {
  64. options.statisticsDisplayName = nick;
  65. }
  66. if (options.enableEmailInStats && email) {
  67. options.statisticsId = email;
  68. }
  69. if (locationURL) {
  70. options.confID = `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`;
  71. }
  72. options.applicationName = getName();
  73. options.getWiFiStatsMethod = getWiFiStatsMethod;
  74. options.createVADProcessor = createRnnoiseProcessor;
  75. // Disable CallStats, if requessted.
  76. if (options.disableThirdPartyRequests) {
  77. delete options.callStatsID;
  78. delete options.callStatsSecret;
  79. delete options.getWiFiStatsMethod;
  80. }
  81. return options;
  82. }