You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.web.js 3.1KB

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