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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. * Returns true if the toolbox is visible.
  48. *
  49. * @param {Object | Function} stateful - A function or object that can be
  50. * resolved to Redux state by the function {@code toState}.
  51. * @returns {boolean}
  52. */
  53. export function isToolboxVisible(stateful: Object | Function) {
  54. const state = toState(stateful);
  55. const { toolbarConfig } = state['features/base/config'];
  56. const { alwaysVisible } = toolbarConfig || {};
  57. const { enabled, visible } = state['features/toolbox'];
  58. const participantCount = getParticipantCountWithFake(state);
  59. const alwaysVisibleFlag = getFeatureFlag(state, TOOLBOX_ALWAYS_VISIBLE, false);
  60. const enabledFlag = getFeatureFlag(state, TOOLBOX_ENABLED, true);
  61. return enabledFlag && enabled
  62. && (alwaysVisible || visible || participantCount === 1 || alwaysVisibleFlag);
  63. }
  64. /**
  65. * Indicates if the video mute button is disabled or not.
  66. *
  67. * @param {string} state - The state from the Redux store.
  68. * @returns {boolean}
  69. */
  70. export function isVideoMuteButtonDisabled(state: Object) {
  71. const { muted, unmuteBlocked } = state['features/base/media'].video;
  72. return !hasAvailableDevices(state, 'videoInput')
  73. || (unmuteBlocked && Boolean(muted))
  74. || isLocalVideoTrackDesktop(state);
  75. }