diff --git a/lib/components/keyserver-connection-handler.js b/lib/components/keyserver-connection-handler.js index 2a9a4f907..6d00b43e9 100644 --- a/lib/components/keyserver-connection-handler.js +++ b/lib/components/keyserver-connection-handler.js @@ -1,43 +1,65 @@ // @flow import * as React from 'react'; import { logOutActionTypes, useLogOut } from '../actions/user-actions.js'; import { connectionSelector } from '../selectors/keyserver-selectors.js'; +import { IdentityClientContext } from '../shared/identity-client-context.js'; import type { BaseSocketProps } from '../socket/socket.react.js'; import { useDispatchActionPromise } from '../utils/action-utils.js'; import { useSelector } from '../utils/redux-utils.js'; +import { usingCommServicesAccessToken } from '../utils/services-utils.js'; import { ashoatKeyserverID } from '../utils/validation-utils.js'; type Props = { ...BaseSocketProps, +keyserverID: string, +socketComponent: React.ComponentType, }; 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]); + const identityClient = React.useContext( + IdentityClientContext, + )?.identityClient; + React.useEffect(() => { + if (!usingCommServicesAccessToken) { + return; + } + + void (async () => { + try { + await identityClient?.getKeyserverKeys(keyserverID); + } catch (e) { + console.log( + `Error getting keys for keyserver with id ${keyserverID}`, + e, + ); + } + })(); + }, [keyserverID, identityClient]); + if (keyserverID !== ashoatKeyserverID) { return null; } return ; } const Handler: React.ComponentType = React.memo( KeyserverConnectionHandler, ); export default Handler;