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 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { IState } from '../../app/types';
  2. import { IConfig } 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) { // eslint-disable-line @typescript-eslint/no-unused-vars
  12. }
  13. /**
  14. * Returns the dial out url.
  15. *
  16. * @param {Object} state - The state of the app.
  17. * @returns {string}
  18. */
  19. export function getDialOutStatusUrl(state: IState): string | undefined {
  20. return state['features/base/config'].guestDialOutStatusUrl;
  21. }
  22. /**
  23. * Returns the dial out status url.
  24. *
  25. * @param {Object} state - The state of the app.
  26. * @returns {string}
  27. */
  28. export function getDialOutUrl(state: IState): string | undefined {
  29. return state['features/base/config'].guestDialOutUrl;
  30. }
  31. /**
  32. * Returns the replaceParticipant config.
  33. *
  34. * @param {Object} state - The state of the app.
  35. * @returns {boolean}
  36. */
  37. export function getReplaceParticipant(state: IState): string | undefined {
  38. return state['features/base/config'].replaceParticipant;
  39. }
  40. /**
  41. * Returns the list of enabled toolbar buttons.
  42. *
  43. * @param {Object} state - The redux state.
  44. * @returns {Array<string>} - The list of enabled toolbar buttons.
  45. */
  46. export function getToolbarButtons(state: IState): Array<string> {
  47. const { toolbarButtons } = state['features/base/config'];
  48. return Array.isArray(toolbarButtons) ? toolbarButtons : TOOLBAR_BUTTONS;
  49. }
  50. /**
  51. * Checks if the specified button is enabled.
  52. *
  53. * @param {string} buttonName - The name of the button.
  54. * {@link interfaceConfig}.
  55. * @param {Object|Array<string>} state - The redux state or the array with the enabled buttons.
  56. * @returns {boolean} - True if the button is enabled and false otherwise.
  57. */
  58. export function isToolbarButtonEnabled(buttonName: string, state: IState | Array<string>) {
  59. const buttons = Array.isArray(state) ? state : getToolbarButtons(state);
  60. return buttons.includes(buttonName);
  61. }
  62. /**
  63. * Returns whether audio level measurement is enabled or not.
  64. *
  65. * @param {Object} state - The state of the app.
  66. * @returns {boolean}
  67. */
  68. export function areAudioLevelsEnabled(state: IState): boolean {
  69. // Default to false for React Native as audio levels are of no interest to the mobile app.
  70. return navigator.product !== 'ReactNative' && !state['features/base/config'].disableAudioLevels;
  71. }