diff --git a/lib/reducers/calendar-filters-reducer.js b/lib/reducers/calendar-filters-reducer.js --- a/lib/reducers/calendar-filters-reducer.js +++ b/lib/reducers/calendar-filters-reducer.js @@ -17,6 +17,7 @@ filteredThreadIDs, nonThreadCalendarFilters, nonExcludeDeletedCalendarFilters, + nonCommunityCalendarFilters, } from '../selectors/calendar-filter-selectors'; import { threadInFilterList } from '../shared/thread-utils'; import { @@ -24,6 +25,8 @@ defaultCalendarFilters, updateCalendarThreadFilter, clearCalendarThreadFilter, + updateCalendarCommunityFilter, + clearCalendarCommunityFilter, setCalendarDeletedFilter, calendarThreadFilterTypes, } from '../types/filter-types'; @@ -80,6 +83,17 @@ // Adding NOT_DELETED filter return [...state, { type: calendarThreadFilterTypes.NOT_DELETED }]; } + } else if (action.type === updateCalendarCommunityFilter) { + const otherFilters = nonCommunityCalendarFilters(state); + return [ + ...otherFilters, + { + type: calendarThreadFilterTypes.COMMUNITY, + threadIDs: action.payload.threadIDs, + }, + ]; + } else if (action.type === clearCalendarCommunityFilter) { + return nonCommunityCalendarFilters(state); } else if ( action.type === newThreadActionTypes.success || action.type === joinThreadActionTypes.success || diff --git a/lib/selectors/calendar-filter-selectors.js b/lib/selectors/calendar-filter-selectors.js --- a/lib/selectors/calendar-filter-selectors.js +++ b/lib/selectors/calendar-filter-selectors.js @@ -72,6 +72,19 @@ nonExcludeDeletedCalendarFilters, ); +function nonCommunityCalendarFilters( + calendarFilters: $ReadOnlyArray, +): $ReadOnlyArray { + return filterFilters(calendarFilters, calendarThreadFilterTypes.COMMUNITY); +} + +const nonCommunityCalendarFiltersSelector: ( + state: BaseAppState<*>, +) => $ReadOnlyArray = createSelector( + (state: BaseAppState<*>) => state.calendarFilters, + nonCommunityCalendarFilters, +); + function filterExists( calendarFilters: $ReadOnlyArray, filterType: CalendarThreadFilterType, @@ -99,6 +112,8 @@ nonThreadCalendarFiltersSelector, nonExcludeDeletedCalendarFilters, nonExcludeDeletedCalendarFiltersSelector, + nonCommunityCalendarFilters, + nonCommunityCalendarFiltersSelector, filterExists, includeDeletedSelector, };