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.ts 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import { IReduxState } from '../../app/types';
  2. import { IConfig, IDeeplinkingConfig, IDeeplinkingMobileConfig, IDeeplinkingPlatformConfig } from './configType';
  3. import { TOOLBAR_BUTTONS } from './constants';
  4. export * from './functions.any';
  5. /**
  6. * Removes all analytics related options from the given configuration, in case of a libre build.
  7. *
  8. * @param {*} _config - The configuration which needs to be cleaned up.
  9. * @returns {void}
  10. */
  11. export function _cleanupConfig(_config: IConfig) {
  12. return;
  13. }
  14. /**
  15. * Returns the replaceParticipant config.
  16. *
  17. * @param {Object} state - The state of the app.
  18. * @returns {boolean}
  19. */
  20. export function getReplaceParticipant(state: IReduxState): string | undefined {
  21. return state['features/base/config'].replaceParticipant;
  22. }
  23. /**
  24. * Returns the list of enabled toolbar buttons.
  25. *
  26. * @param {Object} state - The redux state.
  27. * @returns {Array<string>} - The list of enabled toolbar buttons.
  28. */
  29. export function getToolbarButtons(state: IReduxState): Array<string> {
  30. const { toolbarButtons, customToolbarButtons } = state['features/base/config'];
  31. const customButtons = customToolbarButtons?.map(({ id }) => id);
  32. const buttons = Array.isArray(toolbarButtons) ? toolbarButtons : TOOLBAR_BUTTONS;
  33. if (customButtons) {
  34. buttons.push(...customButtons);
  35. }
  36. return buttons;
  37. }
  38. /**
  39. * Returns the configuration value of web-hid feature.
  40. *
  41. * @param {Object} state - The state of the app.
  42. * @returns {boolean} True if web-hid feature should be enabled, otherwise false.
  43. */
  44. export function getWebHIDFeatureConfig(state: IReduxState): boolean {
  45. return state['features/base/config'].enableWebHIDFeature || false;
  46. }
  47. /**
  48. * Checks if the specified button is enabled.
  49. *
  50. * @param {string} buttonName - The name of the button.
  51. * {@link interfaceConfig}.
  52. * @param {Object|Array<string>} state - The redux state or the array with the enabled buttons.
  53. * @returns {boolean} - True if the button is enabled and false otherwise.
  54. */
  55. export function isToolbarButtonEnabled(buttonName: string, state: IReduxState | Array<string>) {
  56. const buttons = Array.isArray(state) ? state : getToolbarButtons(state);
  57. return buttons.includes(buttonName);
  58. }
  59. /**
  60. * Returns whether audio level measurement is enabled or not.
  61. *
  62. * @param {Object} state - The state of the app.
  63. * @returns {boolean}
  64. */
  65. export function areAudioLevelsEnabled(state: IReduxState): boolean {
  66. // Default to false for React Native as audio levels are of no interest to the mobile app.
  67. return navigator.product !== 'ReactNative' && !state['features/base/config'].disableAudioLevels;
  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. }