Changeset View
Changeset View
Standalone View
Standalone View
web/selectors/calendar-selectors.js
Show All 38 Lines | const threadIDs = threadInfos | ||||
) | ) | ||||
.map(item => item.id); | .map(item => item.id); | ||||
return new Set(threadIDs); | return new Set(threadIDs); | ||||
} | } | ||||
const filterThreadIDsBelongingToCommunitySelector: ( | const filterThreadIDsBelongingToCommunitySelector: ( | ||||
state: AppState, | state: AppState, | ||||
) => ?$ReadOnlySet<string> = createSelector( | ) => ?$ReadOnlySet<string> = createSelector( | ||||
(state: AppState) => state.communityIDFilter, | (state: AppState) => state.calendarPickedCommunityID, | ||||
threadInfoSelector, | threadInfoSelector, | ||||
(communityIDFilter: ?string, threadInfos: { +[id: string]: ThreadInfo }) => { | ( | ||||
if (!communityIDFilter) { | calendarPickedCommunityID: ?string, | ||||
threadInfos: { +[id: string]: ThreadInfo }, | |||||
) => { | |||||
if (!calendarPickedCommunityID) { | |||||
return null; | return null; | ||||
} | } | ||||
return filterThreadIDsBelongingToCommunity(communityIDFilter, threadInfos); | return filterThreadIDsBelongingToCommunity( | ||||
calendarPickedCommunityID, | |||||
threadInfos, | |||||
); | |||||
}, | }, | ||||
); | ); | ||||
function useCommunityIsPicked(communityID: string): boolean { | function useCommunityIsPicked(communityID: string): boolean { | ||||
const communityIDFilter = useSelector(state => state.communityIDFilter); | const calendarPickedCommunityID = useSelector( | ||||
return communityID === communityIDFilter; | state => state.calendarPickedCommunityID, | ||||
); | |||||
return communityID === calendarPickedCommunityID; | |||||
} | } | ||||
export { | export { | ||||
useFilterThreadInfos, | useFilterThreadInfos, | ||||
useFilterThreadSearchIndex, | useFilterThreadSearchIndex, | ||||
filterThreadIDsBelongingToCommunitySelector, | filterThreadIDsBelongingToCommunitySelector, | ||||
filterThreadIDsBelongingToCommunity, | filterThreadIDsBelongingToCommunity, | ||||
useCommunityIsPicked, | useCommunityIsPicked, | ||||
}; | }; |