diff --git a/lib/reducers/primary-identity-public-key-reducer.js b/lib/reducers/primary-identity-public-key-reducer.js new file mode 100644 --- /dev/null +++ b/lib/reducers/primary-identity-public-key-reducer.js @@ -0,0 +1,25 @@ +// @flow + +import { + logOutActionTypes, + deleteAccountActionTypes, +} from '../actions/user-actions.js'; +import type { BaseAction } from '../types/redux-types.js'; +import { setNewSessionActionType } from '../utils/action-utils.js'; + +const setPrimaryIdentityPublicKey = 'SET_PRIMARY_IDENTITY_PUBLIC_KEY'; +export default function reducePrimaryIdentityPublicKey( + state: ?string, + action: BaseAction, +): ?string { + if (action.type === setPrimaryIdentityPublicKey) { + return action.payload; + } else if ( + action.type === logOutActionTypes.success || + action.type === deleteAccountActionTypes.success || + action.type === setNewSessionActionType + ) { + return null; + } + return state; +} diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -911,7 +911,8 @@ +error: true, +payload: Error, +loadingInfo: LoadingInfo, - }; + } + | { +type: 'SET_PRIMARY_IDENTITY_PUBLIC_KEY', payload: ?string }; export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string); export type SuperAction = {