1 import { type PayloadAction, createSlice } from '@reduxjs/toolkit';
3 import type { InactiveKey } from '@proton/shared/lib/interfaces';
7 addresses: { [key: string]: InactiveKey[] };
10 const name = 'inactiveKeys' as const;
12 export interface InactiveKeysState {
16 const initialState: { user: InactiveKey[]; addresses: { [key: string]: InactiveKey[] } } = {
20 const slice = createSlice({
24 set: (state, action: PayloadAction<{ id: 'user' | string; value: InactiveKey[] }>) => {
25 if (action.payload.id === 'user') {
26 state.user = action.payload.value || [];
28 if (!action.payload.value?.length) {
29 if (state.addresses[action.payload.id]) {
30 delete state.addresses[action.payload.id];
33 state.addresses[action.payload.id] = action.payload.value;
40 export const selectInactiveKeys = (state: InactiveKeysState) => state.inactiveKeys;
42 export const inactiveKeysReducer = slice.reducer;
43 export const inactiveKeysActions = slice.actions;