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

functions.web.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 {
  8. areThereNotifications,
  9. showWarningNotification
  10. } from '../notifications';
  11. import { getOverlayToRender } from '../overlay';
  12. import { createRnnoiseProcessorPromise } from '../rnnoise';
  13. /**
  14. * Returns the result of getWiFiStats from the global NS or does nothing
  15. (returns empty result).
  16. * Fixes a concurrency problem where we need to pass a function when creating
  17. * a JitsiConference, but that method is added to the context later.
  18. *
  19. * @returns {Promise}
  20. * @private
  21. */
  22. const getWiFiStatsMethod = () => {
  23. const gloabalNS = getJitsiMeetGlobalNS();
  24. return gloabalNS.getWiFiStats ? gloabalNS.getWiFiStats() : Promise.resolve('{}');
  25. };
  26. /**
  27. * Shows the suboptimal experience notification if needed.
  28. *
  29. * @param {Function} dispatch - The dispatch method.
  30. * @param {Function} t - The translation function.
  31. * @returns {void}
  32. */
  33. export function maybeShowSuboptimalExperienceNotification(dispatch, t) {
  34. if (isSuboptimalBrowser()) {
  35. dispatch(
  36. showWarningNotification(
  37. {
  38. titleKey: 'notify.suboptimalExperienceTitle',
  39. description: translateToHTML(
  40. t,
  41. 'notify.suboptimalBrowserWarning',
  42. {
  43. recommendedBrowserPageLink: `${window.location.origin}/static/recommendedBrowsers.html`
  44. }
  45. )
  46. }
  47. )
  48. );
  49. }
  50. }
  51. /**
  52. * Tells whether or not the notifications should be displayed within
  53. * the conference feature based on the current Redux state.
  54. *
  55. * @param {Object|Function} stateful - The redux store state.
  56. * @returns {boolean}
  57. */
  58. export function shouldDisplayNotifications(stateful) {
  59. const state = toState(stateful);
  60. const isAnyOverlayVisible = Boolean(getOverlayToRender(state));
  61. const { calleeInfoVisible } = state['features/invite'];
  62. return areThereNotifications(state)
  63. && !isAnyOverlayVisible
  64. && !calleeInfoVisible;
  65. }
  66. /**
  67. * Returns an object aggregating the conference options.
  68. *
  69. * @param {Object|Function} stateful - The redux store state.
  70. * @returns {Object} - Options object.
  71. */
  72. export function getConferenceOptions(stateful) {
  73. const state = toState(stateful);
  74. const options = state['features/base/config'];
  75. const { locationURL } = state['features/base/connection'];
  76. const { tenant } = state['features/base/jwt'];
  77. const { email, name: nick } = getLocalParticipant(state);
  78. if (tenant) {
  79. options.siteID = tenant;
  80. }
  81. if (options.enableDisplayNameInStats && nick) {
  82. options.statisticsDisplayName = nick;
  83. }
  84. if (options.enableEmailInStats && email) {
  85. options.statisticsId = email;
  86. }
  87. options.applicationName = getName();
  88. options.getWiFiStatsMethod = getWiFiStatsMethod;
  89. options.confID = `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`;
  90. options.createVADProcessor = createRnnoiseProcessorPromise;
  91. // Disable CallStats, if requessted.
  92. if (options.disableThirdPartyRequests) {
  93. delete options.callStatsID;
  94. delete options.callStatsSecret;
  95. delete options.getWiFiStatsMethod;
  96. }
  97. return options;
  98. }