Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

PollsList.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // @flow
  2. import React, { useCallback, useEffect, useRef } from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { useSelector } from 'react-redux';
  5. import { Icon, IconChatUnread } from '../../../base/icons';
  6. import { browser } from '../../../base/lib-jitsi-meet';
  7. import PollItem from './PollItem';
  8. const PollsList = () => {
  9. const { t } = useTranslation();
  10. const polls = useSelector(state => state['features/polls'].polls);
  11. const pollListEndRef = useRef(null);
  12. const scrollToBottom = useCallback(() => {
  13. if (pollListEndRef.current) {
  14. // Safari does not support options
  15. const param = browser.isSafari()
  16. ? false : {
  17. behavior: 'smooth',
  18. block: 'end',
  19. inline: 'nearest'
  20. };
  21. pollListEndRef.current.scrollIntoView(param);
  22. }
  23. }, [ pollListEndRef.current ]);
  24. useEffect(() => {
  25. scrollToBottom();
  26. }, [ polls ]);
  27. const listPolls = Object.keys(polls);
  28. return (
  29. <>
  30. {listPolls.length === 0
  31. ? <div className = 'pane-content'>
  32. <Icon
  33. className = 'empty-pane-icon'
  34. src = { IconChatUnread } />
  35. <span className = 'empty-pane-message'>{t('polls.results.empty')}</span>
  36. </div>
  37. : listPolls.map((id, index) => (
  38. <PollItem
  39. key = { id }
  40. pollId = { id }
  41. ref = { listPolls.length - 1 === index ? pollListEndRef : null } />
  42. ))}
  43. </>
  44. );
  45. };
  46. export default PollsList;