diff --git a/web/selectors/thread-selectors.js b/web/selectors/thread-selectors.js --- a/web/selectors/thread-selectors.js +++ b/web/selectors/thread-selectors.js @@ -3,6 +3,7 @@ import invariant from 'invariant'; import * as React from 'react'; import { useDispatch } from 'react-redux'; +import { createSelector } from 'reselect'; import { ENSCacheContext } from 'lib/components/ens-cache-provider.react'; import { createPendingSidebar } from 'lib/shared/thread-utils'; @@ -14,6 +15,7 @@ import { getDefaultTextMessageRules } from '../markdown/rules.react'; import { updateNavInfoActionType } from '../redux/action-types'; +import type { AppState, CalendarCommunityFilter } from '../redux/redux-setup'; import { useSelector } from '../redux/redux-utils'; function useOnClickThread( @@ -107,9 +109,22 @@ ); } +const filteredCommunityThreadIDsSelector: ( + state: AppState, +) => ?$ReadOnlySet = createSelector( + (state: AppState) => state.communityFilter, + (communityFilter: ?CalendarCommunityFilter): ?Set => { + if (!communityFilter || communityFilter.threadIDs.length === 0) { + return null; + } + return new Set(communityFilter.threadIDs); + }, +); + export { useOnClickThread, useThreadIsActive, useOnClickPendingSidebar, useOnClickNewThread, + filteredCommunityThreadIDsSelector, };