diff --git a/lib/components/keyserver-connection-handler.js b/lib/components/keyserver-connection-handler.js --- a/lib/components/keyserver-connection-handler.js +++ b/lib/components/keyserver-connection-handler.js @@ -2,7 +2,11 @@ import * as React from 'react'; +import { logOutActionTypes, useLogOut } from '../actions/user-actions.js'; +import { connectionSelector } from '../selectors/keyserver-selectors.js'; import type { BaseSocketProps } from '../socket/socket.react.js'; +import { useDispatchActionPromise } from '../utils/action-utils.js'; +import { useSelector } from '../utils/redux-utils.js'; import { ashoatKeyserverID } from '../utils/validation-utils.js'; type Props = { @@ -12,6 +16,20 @@ }; function KeyserverConnectionHandler(props: Props) { const { socketComponent: Socket, keyserverID, ...rest } = props; + + const dispatchActionPromise = useDispatchActionPromise(); + const callLogOut = useLogOut(); + + const hasConnectionIssue = useSelector( + state => !!connectionSelector(keyserverID)(state)?.connectionIssue, + ); + + React.useEffect(() => { + if (hasConnectionIssue) { + void dispatchActionPromise(logOutActionTypes, callLogOut()); + } + }, [callLogOut, hasConnectionIssue, dispatchActionPromise]); + if (keyserverID !== ashoatKeyserverID) { return null; } 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 @@ -301,12 +301,13 @@ action.type === deleteKeyserverAccountActionTypes.success ) { // We want to remove all keyservers but Ashoat's keyserver - const oldConnection = state.keyserverInfos[ashoatKeyserverID].connection; + const { connectionIssue, ...oldConnectionRest } = + state.keyserverInfos[ashoatKeyserverID].connection; const keyserverInfos = { [ashoatKeyserverID]: { ...state.keyserverInfos[ashoatKeyserverID], - connection: { ...oldConnection, queuedActivityUpdates: [] }, + connection: { ...oldConnectionRest, queuedActivityUpdates: [] }, }, };