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.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // @flow
  2. import { getToolbarButtons } from '../base/config';
  3. import { hasAvailableDevices } from '../base/devices';
  4. import { TOOLBAR_TIMEOUT } from './constants';
  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. * @param {Object} state - The redux state.
  20. * @returns {boolean|undefined} - True to indicate that the given toolbar button
  21. * is enabled, false - otherwise.
  22. */
  23. export function isButtonEnabled(name: string, state: Object) {
  24. const toolbarButtons = getToolbarButtons(state);
  25. return toolbarButtons.indexOf(name) !== -1;
  26. }
  27. /**
  28. * Indicates if the toolbox is visible or not.
  29. *
  30. * @param {Object} state - The state from the Redux store.
  31. * @returns {boolean} - True to indicate that the toolbox is visible, false -
  32. * otherwise.
  33. */
  34. export function isToolboxVisible(state: Object) {
  35. const { iAmSipGateway, toolbarConfig: { alwaysVisible } } = state['features/base/config'];
  36. const {
  37. timeoutID,
  38. visible
  39. } = state['features/toolbox'];
  40. const { audioSettingsVisible, videoSettingsVisible } = state['features/settings'];
  41. return Boolean(!iAmSipGateway && (timeoutID || visible || alwaysVisible
  42. || audioSettingsVisible || videoSettingsVisible));
  43. }
  44. /**
  45. * Indicates if the audio settings button is disabled or not.
  46. *
  47. * @param {Object} state - The state from the Redux store.
  48. * @returns {boolean}
  49. */
  50. export function isAudioSettingsButtonDisabled(state: Object) {
  51. return (!hasAvailableDevices(state, 'audioInput')
  52. && !hasAvailableDevices(state, 'audioOutput'))
  53. || state['features/base/config'].startSilent;
  54. }
  55. /**
  56. * Indicates if the video settings button is disabled or not.
  57. *
  58. * @param {Object} state - The state from the Redux store.
  59. * @returns {boolean}
  60. */
  61. export function isVideoSettingsButtonDisabled(state: Object) {
  62. return !hasAvailableDevices(state, 'videoInput');
  63. }
  64. /**
  65. * Indicates if the video mute button is disabled or not.
  66. *
  67. * @param {Object} state - The state from the Redux store.
  68. * @returns {boolean}
  69. */
  70. export function isVideoMuteButtonDisabled(state: Object) {
  71. return !hasAvailableDevices(state, 'videoInput');
  72. }
  73. /**
  74. * If an overflow drawer should be displayed or not.
  75. * This is usually done for mobile devices or on narrow screens.
  76. *
  77. * @param {Object} state - The state from the Redux store.
  78. * @returns {boolean}
  79. */
  80. export function showOverflowDrawer(state: Object) {
  81. return state['features/toolbox'].overflowDrawer;
  82. }
  83. /**
  84. * Indicates whether the toolbox is enabled or not.
  85. *
  86. * @param {Object} state - The state from the Redux store.
  87. * @returns {boolean}
  88. */
  89. export function isToolboxEnabled(state: Object) {
  90. return state['features/toolbox'].enabled;
  91. }
  92. /**
  93. * Returns the toolbar timeout from config or the default value.
  94. *
  95. * @param {Object} state - The state from the Redux store.
  96. * @returns {number} - Toolbar timeout in miliseconds.
  97. */
  98. export function getToolbarTimeout(state: Object) {
  99. const { toolbarConfig: { timeout } } = state['features/base/config'];
  100. return timeout || TOOLBAR_TIMEOUT;
  101. }