diff --git a/web/selectors/calendar-selectors.js b/web/selectors/calendar-selectors.js --- a/web/selectors/calendar-selectors.js +++ b/web/selectors/calendar-selectors.js @@ -54,9 +54,15 @@ }, ); +function useCommunityIsPicked(communityID: string): boolean { + const communityIDFilter = useSelector(state => state.communityIDFilter); + return communityID === communityIDFilter; +} + export { useFilterThreadInfos, useFilterThreadSearchIndex, threadIDsBelongingToCommunitySelector, threadIDsBelongingToCommunity, + useCommunityIsPicked, }; diff --git a/web/sidebar/community-drawer-item-handlers.react.js b/web/sidebar/community-drawer-item-handlers.react.js --- a/web/sidebar/community-drawer-item-handlers.react.js +++ b/web/sidebar/community-drawer-item-handlers.react.js @@ -3,12 +3,10 @@ import * as React from 'react'; import { useDispatch } from 'react-redux'; -import { - updateCalendarThreadFilter, - calendarThreadFilterTypes, -} from 'lib/types/filter-types'; import type { ThreadInfo } from 'lib/types/thread-types'; +import { updateCalendarCommunityFilter } from '../redux/action-types'; +import { useCommunityIsPicked } from '../selectors/calendar-selectors'; import { useOnClickThread, useThreadIsActive, @@ -41,18 +39,13 @@ const { setHandler, threadInfo } = props; const dispatch = useDispatch(); - const onClick = React.useCallback( - () => - dispatch({ - type: updateCalendarThreadFilter, - payload: { - type: calendarThreadFilterTypes.THREAD_LIST, - threadIDs: [threadInfo.id], - }, - }), - [dispatch, threadInfo.id], - ); - const isActive = false; + const onClick = React.useCallback(() => { + dispatch({ + type: updateCalendarCommunityFilter, + payload: threadInfo.id, + }); + }, [dispatch, threadInfo.id]); + const isActive = useCommunityIsPicked(threadInfo.id); const handler = React.useMemo(() => ({ onClick, isActive }), [ onClick,