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.ts 3.1KB

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