diff --git a/lib/reducers/keyserver-reducer.js b/lib/reducers/keyserver-reducer.js --- a/lib/reducers/keyserver-reducer.js +++ b/lib/reducers/keyserver-reducer.js @@ -4,7 +4,10 @@ import { reduceDeviceToken } from './device-token-reducer.js'; import reduceLastCommunicatedPlatformDetails from './last-communicated-platform-details-reducer.js'; import reduceUpdatesCurrentAsOf from './updates-reducer.js'; -import { addKeyserverActionType } from '../actions/keyserver-actions.js'; +import { + addKeyserverActionType, + removeKeyserverActionType, +} from '../actions/keyserver-actions.js'; import { siweAuthActionTypes } from '../actions/siwe-actions.js'; import { logInActionTypes, @@ -56,6 +59,23 @@ }, }, }; + } else if (action.type === removeKeyserverActionType) { + const filteredKeys = Object.keys(state.keyserverInfos).filter( + key => key !== action.payload.keyserverAdminUserID, + ); + + const filteredKeyserverInfos = filteredKeys.reduce( + (newKeyserverInfos, key) => { + newKeyserverInfos[key] = state.keyserverInfos[key]; + return newKeyserverInfos; + }, + {}, + ); + + return { + ...state, + keyserverInfos: filteredKeyserverInfos, + }; } else if (action.type === resetUserStateActionType) { // this action is only dispatched on native const stateCookie = state.keyserverInfos[ashoatKeyserverID]?.cookie;