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.native.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // @flow
  2. import { hasAvailableDevices } from '../base/devices';
  3. import { TOOLBOX_ALWAYS_VISIBLE, getFeatureFlag, TOOLBOX_ENABLED } from '../base/flags';
  4. import { getParticipantCountWithFake } from '../base/participants';
  5. import { toState } from '../base/redux';
  6. import { isLocalVideoTrackDesktop } from '../base/tracks';
  7. export * from './functions.any';
  8. const WIDTH = {
  9. FIT_9_ICONS: 560,
  10. FIT_8_ICONS: 500,
  11. FIT_7_ICONS: 440,
  12. FIT_6_ICONS: 380
  13. };
  14. /**
  15. * Returns a set of the buttons that are shown in the toolbar
  16. * but removed from the overflow menu, based on the width of the screen.
  17. *
  18. * @param {number} width - The width of the screen.
  19. * @returns {Set}
  20. */
  21. export function getMovableButtons(width: number): Set<string> {
  22. let buttons = [];
  23. switch (true) {
  24. case width >= WIDTH.FIT_9_ICONS: {
  25. buttons = [ 'togglecamera', 'chat', 'participantspane', 'raisehand', 'tileview' ];
  26. break;
  27. }
  28. case width >= WIDTH.FIT_8_ICONS: {
  29. buttons = [ 'chat', 'togglecamera', 'raisehand', 'tileview' ];
  30. break;
  31. }
  32. case width >= WIDTH.FIT_7_ICONS: {
  33. buttons = [ 'chat', 'togglecamera', 'raisehand' ];
  34. break;
  35. }
  36. case width >= WIDTH.FIT_6_ICONS: {
  37. buttons = [ 'chat', 'togglecamera' ];
  38. break;
  39. }
  40. default: {
  41. buttons = [ 'chat' ];
  42. }
  43. }
  44. return new Set(buttons);
  45. }
  46. /**
  47. * Indicates if the desktop share button is disabled or not.
  48. *
  49. * @param {Object} state - The state from the Redux store.
  50. * @returns {boolean}
  51. */
  52. export function isDesktopShareButtonDisabled(state: Object) {
  53. const { muted, unmuteBlocked } = state['features/base/media'].video;
  54. const videoOrShareInProgress = !muted || isLocalVideoTrackDesktop(state);
  55. return unmuteBlocked && !videoOrShareInProgress;
  56. }
  57. /**
  58. * Returns true if the toolbox is visible.
  59. *
  60. * @param {Object | Function} stateful - A function or object that can be
  61. * resolved to Redux state by the function {@code toState}.
  62. * @returns {boolean}
  63. */
  64. export function isToolboxVisible(stateful: Object | Function) {
  65. const state = toState(stateful);
  66. const { toolbarConfig } = state['features/base/config'];
  67. const { alwaysVisible } = toolbarConfig || {};
  68. const { enabled, visible } = state['features/toolbox'];
  69. const participantCount = getParticipantCountWithFake(state);
  70. const alwaysVisibleFlag = getFeatureFlag(state, TOOLBOX_ALWAYS_VISIBLE, false);
  71. const enabledFlag = getFeatureFlag(state, TOOLBOX_ENABLED, true);
  72. return enabledFlag && enabled
  73. && (alwaysVisible || visible || participantCount === 1 || alwaysVisibleFlag);
  74. }
  75. /**
  76. * Indicates if the video mute button is disabled or not.
  77. *
  78. * @param {string} state - The state from the Redux store.
  79. * @returns {boolean}
  80. */
  81. export function isVideoMuteButtonDisabled(state: Object) {
  82. const { muted, unmuteBlocked } = state['features/base/media'].video;
  83. return !hasAvailableDevices(state, 'videoInput')
  84. || (unmuteBlocked && Boolean(muted))
  85. || isLocalVideoTrackDesktop(state);
  86. }