您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.native.js 2.4KB

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