Page MenuHomePhabricator

D6645.diff
No OneTemporary

D6645.diff

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
@@ -8,6 +8,7 @@
deleteAccountActionTypes,
} from 'lib/actions/user-actions.js';
import baseReducer from 'lib/reducers/master-reducer.js';
+import { nonThreadCalendarFilters } from 'lib/selectors/calendar-filter-selectors.js';
import { mostRecentlyReadThreadSelector } from 'lib/selectors/thread-selectors.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
import { invalidSessionDowngrade } from 'lib/shared/account-utils.js';
@@ -15,7 +16,10 @@
import type { DraftStore } from 'lib/types/draft-types.js';
import type { EnabledApps } from 'lib/types/enabled-apps.js';
import type { EntryStore } from 'lib/types/entry-types.js';
-import type { CalendarFilter } from 'lib/types/filter-types.js';
+import {
+ type CalendarFilter,
+ calendarThreadFilterTypes,
+} from 'lib/types/filter-types.js';
import type { LifecycleState } from 'lib/types/lifecycle-state-types.js';
import type { LoadingStatus } from 'lib/types/loading-types.js';
import type { MessageStore } from 'lib/types/message-types.js';
@@ -32,6 +36,8 @@
setDeviceIDActionType,
updateNavInfoActionType,
updateWindowDimensionsActionType,
+ updateCalendarCommunityFilter,
+ clearCalendarCommunityFilter,
} from './action-types.js';
import { reduceDeviceID } from './device-id-reducer.js';
import reduceNavInfo from './nav-reducer.js';
@@ -40,6 +46,7 @@
setPrimaryIdentityPublicKey,
} from './primary-identity-public-key-reducer.js';
import { getVisibility } from './visibility.js';
+import { filterThreadIDsBelongingToCommunity } from '../selectors/calendar-selectors.js';
import { activeThreadSelector } from '../selectors/nav-selectors.js';
import { type NavInfo } from '../types/nav-types.js';
@@ -92,7 +99,15 @@
type: 'SET_DEVICE_ID',
payload: string,
}
- | { +type: 'SET_PRIMARY_IDENTITY_PUBLIC_KEY', payload: ?string };
+ | { +type: 'SET_PRIMARY_IDENTITY_PUBLIC_KEY', payload: ?string }
+ | {
+ +type: 'UPDATE_CALENDAR_COMMUNITY_FILTER',
+ +payload: string,
+ }
+ | {
+ +type: 'CLEAR_CALENDAR_COMMUNITY_FILTER',
+ +payload: void,
+ };
export function reducer(oldState: AppState | void, action: Action): AppState {
invariant(oldState, 'should be set');
@@ -108,6 +123,33 @@
...state,
windowActive: action.payload,
});
+ } else if (action.type === updateCalendarCommunityFilter) {
+ const nonThreadFilters = nonThreadCalendarFilters(state.calendarFilters);
+
+ const threadIDs = Array.from(
+ filterThreadIDsBelongingToCommunity(
+ action.payload,
+ state.threadStore.threadInfos,
+ ),
+ );
+ return {
+ ...state,
+ calendarFilters: [
+ ...nonThreadFilters,
+ {
+ type: calendarThreadFilterTypes.THREAD_LIST,
+ threadIDs,
+ },
+ ],
+ communityIDFilter: action.payload,
+ };
+ } else if (action.type === clearCalendarCommunityFilter) {
+ const nonThreadFilters = nonThreadCalendarFilters(state.calendarFilters);
+ return {
+ ...state,
+ calendarFilters: nonThreadFilters,
+ communityIDFilter: null,
+ };
} else if (action.type === setNewSessionActionType) {
if (
invalidSessionDowngrade(

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 12:44 AM (18 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2684216
Default Alt Text
D6645.diff (3 KB)

Event Timeline