diff --git a/keyserver/src/responders/website-responders.js b/keyserver/src/responders/website-responders.js --- a/keyserver/src/responders/website-responders.js +++ b/keyserver/src/responders/website-responders.js @@ -399,6 +399,7 @@ updatesCurrentAsOf: currentAsOfPromise, loadingStatuses: {}, calendarFilters: defaultCalendarFilters, + communityPickerStore: { chat: null, calendar: null }, // We can use paths local to the on web urlPrefix: '', windowDimensions: { width: 0, height: 0 }, diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js --- a/web/redux/redux-setup.js +++ b/web/redux/redux-setup.js @@ -61,6 +61,11 @@ export type WindowDimensions = { width: number, height: number }; +export type CommunityPickerStore = { + +chat: ?string, + +calendar: ?string, +}; + export type AppState = { navInfo: NavInfo, deviceID: ?string, @@ -74,7 +79,7 @@ updatesCurrentAsOf: number, loadingStatuses: { [key: string]: { [idx: number]: LoadingStatus } }, calendarFilters: $ReadOnlyArray, - calendarPickedCommunityID: ?string, + communityPickerStore: CommunityPickerStore, urlPrefix: string, windowDimensions: WindowDimensions, cookie?: void, @@ -156,14 +161,20 @@ threadIDs, }, ], - calendarPickedCommunityID: action.payload, + communityPickerStore: { + ...state.communityPickerStore, + calendar: action.payload, + }, }; } else if (action.type === clearCalendarCommunityFilter) { const nonThreadFilters = nonThreadCalendarFilters(state.calendarFilters); return { ...state, calendarFilters: nonThreadFilters, - calendarPickedCommunityID: null, + communityPickerStore: { + ...state.communityPickerStore, + calendar: null, + }, }; } else if (action.type === setNewSessionActionType) { if ( 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 @@ -44,7 +44,7 @@ const filterThreadIDsBelongingToCommunitySelector: ( state: AppState, ) => ?$ReadOnlySet = createSelector( - (state: AppState) => state.calendarPickedCommunityID, + (state: AppState) => state.communityPickerStore.calendar, threadInfoSelector, ( calendarPickedCommunityID: ?string, @@ -60,9 +60,9 @@ }, ); -function useCommunityIsPicked(communityID: string): boolean { +function useCommunityIsPickedCalendar(communityID: string): boolean { const calendarPickedCommunityID = useSelector( - state => state.calendarPickedCommunityID, + state => state.communityPickerStore.calendar, ); return communityID === calendarPickedCommunityID; } @@ -72,5 +72,5 @@ useFilterThreadSearchIndex, filterThreadIDsBelongingToCommunitySelector, filterThreadIDsBelongingToCommunity, - useCommunityIsPicked, + useCommunityIsPickedCalendar, }; 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 @@ -113,7 +113,7 @@ state => state.navInfo.activeChatThreadID, ); const pickedCommunityID = useSelector( - state => state.calendarPickedCommunityID, + state => state.communityPickerStore.calendar, ); const inCalendar = useSelector(state => state.navInfo.tab === 'calendar'); 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 @@ -7,7 +7,7 @@ import type { CommunityDrawerItemHandler } from './community-drawer-item-handler.react.js'; import { updateCalendarCommunityFilter } from '../redux/action-types.js'; -import { useCommunityIsPicked } from '../selectors/calendar-selectors.js'; +import { useCommunityIsPickedCalendar } from '../selectors/calendar-selectors.js'; import { useOnClickThread, useThreadIsActive, @@ -45,7 +45,7 @@ payload: threadInfo.id, }); }, [dispatch, threadInfo.id]); - const isActive = useCommunityIsPicked(threadInfo.id); + const isActive = useCommunityIsPickedCalendar(threadInfo.id); const handler = React.useMemo( () => ({ onClick, isActive }),