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

functions.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // @flow
  2. /**
  3. * Selector creator for determining if poll results should be displayed or not.
  4. *
  5. * @param {string} id - Id of the poll.
  6. * @returns {Function}
  7. */
  8. export function shouldShowResults(id: string) {
  9. return function(state: Object) {
  10. return Boolean(state['features/polls']?.polls[id].showResults);
  11. };
  12. }
  13. /**
  14. * Selector creator for polls.
  15. *
  16. * @param {string} pollId - Id of the poll to get.
  17. * @returns {Function}
  18. */
  19. export function getPoll(pollId: string) {
  20. return function(state: Object) {
  21. return state['features/polls'].polls[pollId];
  22. };
  23. }
  24. /**
  25. * Selector for calculating the number of unread poll messages.
  26. *
  27. * @param {Object} state - The redux state.
  28. * @returns {number} The number of unread messages.
  29. */
  30. export function getUnreadPollCount(state: Object) {
  31. const { nbUnreadPolls } = state['features/polls'];
  32. return nbUnreadPolls;
  33. }
  34. /**
  35. * Determines if the submit poll answer button should be disabled.
  36. *
  37. * @param {Array<boolean>} checkBoxStates - The states of the checkboxes.
  38. * @returns {boolean}
  39. */
  40. export function isSubmitAnswerDisabled(checkBoxStates: Array<boolean>) {
  41. return !checkBoxStates.find(checked => checked);
  42. }