Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

SpeakerStatsLabel.tsx 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React from 'react';
  2. import { useDispatch, useSelector } from 'react-redux';
  3. import { IReduxState } from '../../../app/types';
  4. import { openDialog } from '../../../base/dialog/actions';
  5. import { IconUsers } from '../../../base/icons/svg';
  6. import Label from '../../../base/label/components/web/Label';
  7. import { COLORS } from '../../../base/label/constants';
  8. import { getParticipantCount } from '../../../base/participants/functions';
  9. import SpeakerStats from '../../../speaker-stats/components/web/SpeakerStats';
  10. import { isSpeakerStatsDisabled } from '../../../speaker-stats/functions';
  11. import { iAmVisitor } from '../../../visitors/functions';
  12. /**
  13. * ParticipantsCount react component.
  14. * Displays the number of participants and opens Speaker stats on click.
  15. *
  16. * @class ParticipantsCount
  17. */
  18. function SpeakerStatsLabel() {
  19. const conference = useSelector((state: IReduxState) => state['features/base/conference'].conference);
  20. let count = useSelector(getParticipantCount);
  21. const iAmVisitorState = useSelector(iAmVisitor);
  22. const _isSpeakerStatsDisabled = useSelector(isSpeakerStatsDisabled);
  23. const dispatch = useDispatch();
  24. // visitor has hidden its own video and should not count itself
  25. if (iAmVisitorState) {
  26. count--;
  27. }
  28. const onClick = () => {
  29. dispatch(openDialog(SpeakerStats, { conference }));
  30. };
  31. if (count <= 2 || _isSpeakerStatsDisabled) {
  32. return null;
  33. }
  34. return (
  35. <Label
  36. color = { COLORS.white }
  37. icon = { IconUsers }
  38. iconColor = '#fff'
  39. // eslint-disable-next-line react/jsx-no-bind
  40. onClick = { onClick }
  41. text = { `${count}` } />
  42. );
  43. }
  44. export default SpeakerStatsLabel;