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.

123456789101112131415161718192021222324252627282930313233
  1. // @flow
  2. /**
  3. * Should poll results be shown.
  4. *
  5. * @param {Object} state - Global state.
  6. * @param {string} id - Id of the poll.
  7. * @returns {boolean} Should poll results be shown.
  8. */
  9. export const shouldShowResults = (state: Object, id: string) => Boolean(state['features/polls']?.polls[id].showResults);
  10. /**
  11. * Selector for calculating the number of unread poll messages.
  12. *
  13. * @param {Object} state - The redux state.
  14. * @returns {number} The number of unread messages.
  15. */
  16. export function getUnreadPollCount(state: Object) {
  17. const { nbUnreadPolls } = state['features/polls'];
  18. return nbUnreadPolls;
  19. }
  20. /**
  21. * Determines if the submit poll answer button should be disabled.
  22. *
  23. * @param {Array<boolean>} checkBoxStates - The states of the checkboxes.
  24. * @returns {boolean}
  25. */
  26. export function isSubmitAnswerDisabled(checkBoxStates: Array<boolean>) {
  27. return !checkBoxStates.find(checked => checked);
  28. }