Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

functions.web.ts 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. * Checks if the specified button is enabled.
  40. *
  41. * @param {string} buttonName - The name of the button.
  42. * {@link interfaceConfig}.
  43. * @param {Object|Array<string>} state - The redux state or the array with the enabled buttons.
  44. * @returns {boolean} - True if the button is enabled and false otherwise.
  45. */
  46. export function isToolbarButtonEnabled(buttonName: string, state: IReduxState | Array<string>) {
  47. const buttons = Array.isArray(state) ? state : getToolbarButtons(state);
  48. return buttons.includes(buttonName);
  49. }
  50. /**
  51. * Returns whether audio level measurement is enabled or not.
  52. *
  53. * @param {Object} state - The state of the app.
  54. * @returns {boolean}
  55. */
  56. export function areAudioLevelsEnabled(state: IReduxState): boolean {
  57. // Default to false for React Native as audio levels are of no interest to the mobile app.
  58. return navigator.product !== 'ReactNative' && !state['features/base/config'].disableAudioLevels;
  59. }
  60. /**
  61. * Sets the defaults for deeplinking.
  62. *
  63. * @param {IDeeplinkingConfig} deeplinking - The deeplinking config.
  64. * @returns {void}
  65. */
  66. export function _setDeeplinkingDefaults(deeplinking: IDeeplinkingConfig) {
  67. const {
  68. desktop = {} as IDeeplinkingPlatformConfig,
  69. android = {} as IDeeplinkingMobileConfig,
  70. ios = {} as IDeeplinkingMobileConfig
  71. } = deeplinking;
  72. desktop.appName = desktop.appName || 'Jitsi Meet';
  73. ios.appName = ios.appName || 'Jitsi Meet';
  74. ios.appScheme = ios.appScheme || 'org.jitsi.meet';
  75. ios.downloadLink = ios.downloadLink
  76. || 'https://itunes.apple.com/us/app/jitsi-meet/id1165103905';
  77. if (ios.dynamicLink) {
  78. ios.dynamicLink.apn = ios.dynamicLink.apn || 'org.jitsi.meet';
  79. ios.dynamicLink.appCode = ios.dynamicLink.appCode || 'w2atb';
  80. ios.dynamicLink.ibi = ios.dynamicLink.ibi || 'com.atlassian.JitsiMeet.ios';
  81. ios.dynamicLink.isi = ios.dynamicLink.isi || '1165103905';
  82. }
  83. android.appName = android.appName || 'Jitsi Meet';
  84. android.appScheme = android.appScheme || 'org.jitsi.meet';
  85. android.downloadLink = android.downloadLink
  86. || 'https://play.google.com/store/apps/details?id=org.jitsi.meet';
  87. android.appPackage = android.appPackage || 'org.jitsi.meet';
  88. android.fDroidUrl = android.fDroidUrl || 'https://f-droid.org/en/packages/org.jitsi.meet/';
  89. if (android.dynamicLink) {
  90. android.dynamicLink.apn = android.dynamicLink.apn || 'org.jitsi.meet';
  91. android.dynamicLink.appCode = android.dynamicLink.appCode || 'w2atb';
  92. android.dynamicLink.ibi = android.dynamicLink.ibi || 'com.atlassian.JitsiMeet.ios';
  93. android.dynamicLink.isi = android.dynamicLink.isi || '1165103905';
  94. }
  95. }
  96. /**
  97. * Returns the list of buttons that have that notify the api when clicked.
  98. *
  99. * @param {Object} state - The redux state.
  100. * @returns {Array} - The list of buttons.
  101. */
  102. export function getButtonsWithNotifyClick(state: IReduxState): Array<{ key: string; preventExecution: boolean; }> {
  103. const { buttonsWithNotifyClick, customToolbarButtons } = state['features/base/config'];
  104. const customButtons = customToolbarButtons?.map(({ id }) => {
  105. return {
  106. key: id,
  107. preventExecution: false
  108. };
  109. });
  110. const buttons = Array.isArray(buttonsWithNotifyClick)
  111. ? buttonsWithNotifyClick as Array<{ key: string; preventExecution: boolean; }>
  112. : [];
  113. if (customButtons) {
  114. buttons.push(...customButtons);
  115. }
  116. return buttons;
  117. }