diff --git a/lib/reducers/nav-reducer.js b/lib/reducers/nav-reducer.js --- a/lib/reducers/nav-reducer.js +++ b/lib/reducers/nav-reducer.js @@ -3,15 +3,20 @@ import { updateCalendarQueryActionTypes } from '../actions/entry-actions.js'; import { siweAuthActionTypes } from '../actions/siwe-actions.js'; import { + identityRegisterActionTypes, logInActionTypes, keyserverRegisterActionTypes, + logOutActionTypes, + deleteAccountActionTypes, } from '../actions/user-actions.js'; +import { defaultCalendarQuery } from '../types/entry-types.js'; import type { BaseNavInfo } from '../types/nav-types.js'; import type { BaseAction } from '../types/redux-types.js'; import { fullStateSyncActionType, incrementalStateSyncActionType, } from '../types/socket-types.js'; +import { getConfig } from '../utils/config.js'; export default function reduceBaseNavInfo( state: T, @@ -36,6 +41,16 @@ !action.payload.calendarQueryAlreadyUpdated ) { const { startDate, endDate } = action.payload.calendarQuery; + return { ...state, startDate, endDate }; + } else if ( + action.type === logOutActionTypes.success || + action.type === deleteAccountActionTypes.success || + action.type === identityRegisterActionTypes.success + ) { + const { startDate, endDate } = defaultCalendarQuery( + getConfig().platformDetails.platform, + ); + return { ...state, startDate, endDate }; } return state; diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js --- a/native/redux/redux-setup.js +++ b/native/redux/redux-setup.js @@ -13,6 +13,7 @@ logInActionTypes, keyserverAuthActionTypes, deleteKeyserverAccountActionTypes, + identityRegisterActionTypes, } from 'lib/actions/user-actions.js'; import { setNewSessionActionType } from 'lib/keyserver-conn/keyserver-conn-types.js'; import type { ThreadStoreOperation } from 'lib/ops/thread-store-ops.js'; @@ -28,6 +29,7 @@ import { rehydrateActionType } from 'lib/types/redux-types.js'; import type { SetSessionPayload } from 'lib/types/session-types.js'; import { reduxLoggerMiddleware } from 'lib/utils/action-logger.js'; +import { resetUserSpecificStateOnIdentityActions } from 'lib/utils/reducers-utils.js'; import { ashoatKeyserverID } from 'lib/utils/validation-utils.js'; import { @@ -46,6 +48,7 @@ import { persistConfig, setPersistor } from './persist.js'; import { onStateDifference } from './redux-debug-utils.js'; import { processDBStoreOperations } from './redux-utils.js'; +import { nonUserSpecificFieldsNative } from './state-types.js'; import type { AppState } from './state-types.js'; import { getGlobalNavContext } from '../navigation/icky-global.js'; import { activeMessageListSelector } from '../navigation/nav-selectors.js'; @@ -116,21 +119,7 @@ action.payload.preRequestUserState, action.payload.keyserverID, )) || - (action.type === logOutActionTypes.success && - invalidSessionDowngrade( - state, - action.payload.currentUserInfo, - action.payload.preRequestUserState, - ashoatKeyserverID, - )) || (action.type === deleteKeyserverAccountActionTypes.success && - invalidSessionDowngrade( - state, - action.payload.currentUserInfo, - action.payload.preRequestUserState, - ashoatKeyserverID, - )) || - (action.type === deleteAccountActionTypes.success && invalidSessionDowngrade( state, action.payload.currentUserInfo, @@ -142,6 +131,35 @@ ...state, loadingStatuses: reduceLoadingStatuses(state.loadingStatuses, action), }; + } else if ( + action.type === logOutActionTypes.success || + action.type === deleteAccountActionTypes.success + ) { + if ( + invalidSessionDowngrade( + state, + action.payload.currentUserInfo, + action.payload.preRequestUserState, + ashoatKeyserverID, + ) + ) { + return { + ...state, + loadingStatuses: reduceLoadingStatuses(state.loadingStatuses, action), + }; + } + + state = resetUserSpecificStateOnIdentityActions( + state, + defaultState, + nonUserSpecificFieldsNative, + ); + } else if (action.type === identityRegisterActionTypes.success) { + state = resetUserSpecificStateOnIdentityActions( + state, + defaultState, + nonUserSpecificFieldsNative, + ); } if ( (action.type === setNewSessionActionType && 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 @@ -7,6 +7,7 @@ logOutActionTypes, deleteKeyserverAccountActionTypes, deleteAccountActionTypes, + identityRegisterActionTypes, } from 'lib/actions/user-actions.js'; import { setNewSessionActionType } from 'lib/keyserver-conn/keyserver-conn-types.js'; import { @@ -39,6 +40,7 @@ import type { ThreadStore } from 'lib/types/thread-types.js'; import type { CurrentUserInfo, UserStore } from 'lib/types/user-types.js'; import type { NotifPermissionAlertInfo } from 'lib/utils/push-alerts.js'; +import { resetUserSpecificStateOnIdentityActions } from 'lib/utils/reducers-utils.js'; import { ashoatKeyserverID } from 'lib/utils/validation-utils.js'; import { @@ -49,6 +51,7 @@ } from './action-types.js'; import { reduceCommunityPickerStore } from './community-picker-reducer.js'; import { reduceCryptoStore, setCryptoStore } from './crypto-store-reducer.js'; +import { defaultWebState } from './default-state.js'; import reduceNavInfo from './nav-reducer.js'; import { onStateDifference } from './redux-debug-utils.js'; import { getVisibility } from './visibility.js'; @@ -217,32 +220,47 @@ }, }; } else if ( - (action.type === logOutActionTypes.success && - invalidSessionDowngrade( - oldState, - action.payload.currentUserInfo, - action.payload.preRequestUserState, - ashoatKeyserverID, - )) || - (action.type === deleteKeyserverAccountActionTypes.success && - invalidSessionDowngrade( - oldState, - action.payload.currentUserInfo, - action.payload.preRequestUserState, - ashoatKeyserverID, - )) || - (action.type === deleteAccountActionTypes.success && - invalidSessionDowngrade( - state, - action.payload.currentUserInfo, - action.payload.preRequestUserState, - ashoatKeyserverID, - )) + action.type === deleteKeyserverAccountActionTypes.success && + invalidSessionDowngrade( + oldState, + action.payload.currentUserInfo, + action.payload.preRequestUserState, + ashoatKeyserverID, + ) ) { return { ...oldState, loadingStatuses: reduceLoadingStatuses(state.loadingStatuses, action), }; + } else if ( + action.type === logOutActionTypes.success || + action.type === deleteAccountActionTypes.success + ) { + if ( + invalidSessionDowngrade( + oldState, + action.payload.currentUserInfo, + action.payload.preRequestUserState, + ashoatKeyserverID, + ) + ) { + return { + ...oldState, + loadingStatuses: reduceLoadingStatuses(state.loadingStatuses, action), + }; + } + + state = resetUserSpecificStateOnIdentityActions( + state, + defaultWebState, + nonUserSpecificFieldsWeb, + ); + } else if (action.type === identityRegisterActionTypes.success) { + state = resetUserSpecificStateOnIdentityActions( + state, + defaultWebState, + nonUserSpecificFieldsWeb, + ); } if (