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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // @flow
  2. import { hasAvailableDevices } from '../base/devices';
  3. import { isMobileBrowser } from '../base/environment/utils';
  4. declare var interfaceConfig: Object;
  5. /**
  6. * Helper for getting the height of the toolbox.
  7. *
  8. * @returns {number} The height of the toolbox.
  9. */
  10. export function getToolboxHeight() {
  11. const toolbox = document.getElementById('new-toolbox');
  12. return (toolbox && toolbox.clientHeight) || 0;
  13. }
  14. /**
  15. * Indicates if a toolbar button is enabled.
  16. *
  17. * @param {string} name - The name of the setting section as defined in
  18. * interface_config.js.
  19. * @returns {boolean} - True to indicate that the given toolbar button
  20. * is enabled, false - otherwise.
  21. */
  22. export function isButtonEnabled(name: string) {
  23. return interfaceConfig.TOOLBAR_BUTTONS.indexOf(name) !== -1;
  24. }
  25. /**
  26. * Indicates if the toolbox is visible or not.
  27. *
  28. * @param {string} state - The state from the Redux store.
  29. * @returns {boolean} - True to indicate that the toolbox is visible, false -
  30. * otherwise.
  31. */
  32. export function isToolboxVisible(state: Object) {
  33. const { iAmSipGateway } = state['features/base/config'];
  34. const {
  35. alwaysVisible,
  36. timeoutID,
  37. visible
  38. } = state['features/toolbox'];
  39. const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
  40. const { isOpen } = state['features/chat'];
  41. const isMobileChatOpen = isMobileBrowser() && isOpen;
  42. return Boolean(!isMobileChatOpen && !iAmSipGateway && (timeoutID || visible || alwaysVisible
  43. || audioSettingsVisible || videoSettingsVisible));
  44. }
  45. /**
  46. * Indicates if the audio settings button is disabled or not.
  47. *
  48. * @param {string} state - The state from the Redux store.
  49. * @returns {boolean}
  50. */
  51. export function isAudioSettingsButtonDisabled(state: Object) {
  52. return (!hasAvailableDevices(state, 'audioInput')
  53. && !hasAvailableDevices(state, 'audioOutput'))
  54. || state['features/base/config'].startSilent;
  55. }
  56. /**
  57. * Indicates if the video settings button is disabled or not.
  58. *
  59. * @param {string} state - The state from the Redux store.
  60. * @returns {boolean}
  61. */
  62. export function isVideoSettingsButtonDisabled(state: Object) {
  63. return !hasAvailableDevices(state, 'videoInput');
  64. }