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

functions.web.ts 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import { IReduxState } from '../../app/types';
  2. import JitsiMeetJS from '../../base/lib-jitsi-meet';
  3. import { IConfig, IDeeplinkingConfig, IDeeplinkingMobileConfig, IDeeplinkingPlatformConfig } from './configType';
  4. import { TOOLBAR_BUTTONS } from './constants';
  5. export * from './functions.any';
  6. /**
  7. * Removes all analytics related options from the given configuration, in case of a libre build.
  8. *
  9. * @param {*} _config - The configuration which needs to be cleaned up.
  10. * @returns {void}
  11. */
  12. export function _cleanupConfig(_config: IConfig) {
  13. return;
  14. }
  15. /**
  16. * Returns the replaceParticipant config.
  17. *
  18. * @param {Object} state - The state of the app.
  19. * @returns {boolean}
  20. */
  21. export function getReplaceParticipant(state: IReduxState): string | undefined {
  22. return state['features/base/config'].replaceParticipant;
  23. }
  24. /**
  25. * Returns the list of enabled toolbar buttons.
  26. *
  27. * @param {Object} state - The redux state.
  28. * @returns {Array<string>} - The list of enabled toolbar buttons.
  29. */
  30. export function getToolbarButtons(state: IReduxState): Array<string> {
  31. const { toolbarButtons, customToolbarButtons } = state['features/base/config'];
  32. const customButtons = customToolbarButtons?.map(({ id }) => id);
  33. const buttons = Array.isArray(toolbarButtons) ? toolbarButtons : TOOLBAR_BUTTONS;
  34. if (customButtons) {
  35. buttons.push(...customButtons);
  36. }
  37. return buttons;
  38. }
  39. /**
  40. * Returns the configuration value of web-hid feature.
  41. *
  42. * @param {Object} state - The state of the app.
  43. * @returns {boolean} True if web-hid feature should be enabled, otherwise false.
  44. */
  45. export function getWebHIDFeatureConfig(state: IReduxState): boolean {
  46. return state['features/base/config'].enableWebHIDFeature || false;
  47. }
  48. /**
  49. * Checks if the specified button is enabled.
  50. *
  51. * @param {string} buttonName - The name of the button.
  52. * {@link interfaceConfig}.
  53. * @param {Object|Array<string>} state - The redux state or the array with the enabled buttons.
  54. * @returns {boolean} - True if the button is enabled and false otherwise.
  55. */
  56. export function isToolbarButtonEnabled(buttonName: string, state: IReduxState | Array<string>) {
  57. const buttons = Array.isArray(state) ? state : getToolbarButtons(state);
  58. return buttons.includes(buttonName);
  59. }
  60. /**
  61. * Returns whether audio level measurement is enabled or not.
  62. *
  63. * @param {Object} state - The state of the app.
  64. * @returns {boolean}
  65. */
  66. export function areAudioLevelsEnabled(state: IReduxState): boolean {
  67. return !state['features/base/config'].disableAudioLevels && JitsiMeetJS.isCollectingLocalStats();
  68. }
  69. /**
  70. * Sets the defaults for deeplinking.
  71. *
  72. * @param {IDeeplinkingConfig} deeplinking - The deeplinking config.
  73. * @returns {void}
  74. */
  75. export function _setDeeplinkingDefaults(deeplinking: IDeeplinkingConfig) {
  76. const {
  77. desktop = {} as IDeeplinkingPlatformConfig,
  78. android = {} as IDeeplinkingMobileConfig,
  79. ios = {} as IDeeplinkingMobileConfig
  80. } = deeplinking;
  81. desktop.appName = desktop.appName || 'Jitsi Meet';
  82. ios.appName = ios.appName || 'Jitsi Meet';
  83. ios.appScheme = ios.appScheme || 'org.jitsi.meet';
  84. ios.downloadLink = ios.downloadLink
  85. || 'https://itunes.apple.com/us/app/jitsi-meet/id1165103905';
  86. if (ios.dynamicLink) {
  87. ios.dynamicLink.apn = ios.dynamicLink.apn || 'org.jitsi.meet';
  88. ios.dynamicLink.appCode = ios.dynamicLink.appCode || 'w2atb';
  89. ios.dynamicLink.ibi = ios.dynamicLink.ibi || 'com.atlassian.JitsiMeet.ios';
  90. ios.dynamicLink.isi = ios.dynamicLink.isi || '1165103905';
  91. }
  92. android.appName = android.appName || 'Jitsi Meet';
  93. android.appScheme = android.appScheme || 'org.jitsi.meet';
  94. android.downloadLink = android.downloadLink
  95. || 'https://play.google.com/store/apps/details?id=org.jitsi.meet';
  96. android.appPackage = android.appPackage || 'org.jitsi.meet';
  97. android.fDroidUrl = android.fDroidUrl || 'https://f-droid.org/en/packages/org.jitsi.meet/';
  98. if (android.dynamicLink) {
  99. android.dynamicLink.apn = android.dynamicLink.apn || 'org.jitsi.meet';
  100. android.dynamicLink.appCode = android.dynamicLink.appCode || 'w2atb';
  101. android.dynamicLink.ibi = android.dynamicLink.ibi || 'com.atlassian.JitsiMeet.ios';
  102. android.dynamicLink.isi = android.dynamicLink.isi || '1165103905';
  103. }
  104. }
  105. /**
  106. * Returns the list of buttons that have that notify the api when clicked.
  107. *
  108. * @param {Object} state - The redux state.
  109. * @returns {Array} - The list of buttons.
  110. */
  111. export function getButtonsWithNotifyClick(state: IReduxState): Array<{ key: string; preventExecution: boolean; }> {
  112. const { buttonsWithNotifyClick, customToolbarButtons } = state['features/base/config'];
  113. const customButtons = customToolbarButtons?.map(({ id }) => {
  114. return {
  115. key: id,
  116. preventExecution: false
  117. };
  118. });
  119. const buttons = Array.isArray(buttonsWithNotifyClick)
  120. ? buttonsWithNotifyClick as Array<{ key: string; preventExecution: boolean; }>
  121. : [];
  122. if (customButtons) {
  123. buttons.push(...customButtons);
  124. }
  125. return buttons;
  126. }