選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

functions.web.js 2.3KB

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