diff --git a/lib/selectors/keyserver-selectors.js b/lib/selectors/keyserver-selectors.js --- a/lib/selectors/keyserver-selectors.js +++ b/lib/selectors/keyserver-selectors.js @@ -126,14 +126,15 @@ for (const key in keyserverInfos) { const keyserverInfo = keyserverInfos[key]; - const keyserverAdminUsername = userInfos[key]?.username; + const keyserverAdminUsername = + userInfos[key]?.username ?? `keyserver${key}`; if (!keyserverAdminUsername) { continue; } const keyserverAdminUserInfo = { - id: userInfos[key].id, + id: key, username: keyserverAdminUsername, }; diff --git a/lib/shared/keyserver-utils.js b/lib/shared/keyserver-utils.js --- a/lib/shared/keyserver-utils.js +++ b/lib/shared/keyserver-utils.js @@ -7,10 +7,13 @@ getVersionActionTypes, } from '../actions/device-actions.js'; import { urlsToIDsSelector } from '../selectors/keyserver-selectors.js'; +import type { VersionResponse } from '../types/device-types.js'; import { useDispatchActionPromise } from '../utils/redux-promise-utils.js'; import { useSelector } from '../utils/redux-utils.js'; -function useIsKeyserverURLValid(keyserverURL?: string): () => Promise { +function useIsKeyserverURLValid( + keyserverURL?: string, +): () => Promise { const urlsToIDs: { +[keyserverID: string]: ?string } = useSelector(urlsToIDsSelector); @@ -50,18 +53,17 @@ return React.useCallback(async () => { if (!keyserverURL) { - return false; + return null; } const getVersionPromise = getVersionCall(); void dispatchActionPromise(getVersionActionTypes, getVersionPromise); - // We don't care about the result; just need to make sure this doesn't throw try { - await getVersionPromise; - return true; + const { versionResponses } = await getVersionPromise; + return versionResponses[Object.keys(versionResponses)[0]]; } catch (e) { - return false; + return null; } }, [dispatchActionPromise, getVersionCall, keyserverURL]); } diff --git a/native/profile/add-keyserver.react.js b/native/profile/add-keyserver.react.js --- a/native/profile/add-keyserver.react.js +++ b/native/profile/add-keyserver.react.js @@ -49,8 +49,8 @@ return; } - const isKeyserverURLValid = await isKeyserverURLValidCallback(); - if (!isKeyserverURLValid) { + const keyserverVersionData = await isKeyserverURLValidCallback(); + if (!keyserverVersionData) { setShowErrorMessage(true); return; } @@ -60,7 +60,7 @@ dispatch({ type: addKeyserverActionType, payload: { - keyserverAdminUserID: currentUserID, + keyserverAdminUserID: keyserverVersionData.ownerID, newKeyserverInfo, }, }); diff --git a/web/modals/keyserver-selection/add-keyserver-modal.react.js b/web/modals/keyserver-selection/add-keyserver-modal.react.js --- a/web/modals/keyserver-selection/add-keyserver-modal.react.js +++ b/web/modals/keyserver-selection/add-keyserver-modal.react.js @@ -46,8 +46,8 @@ return; } - const isKeyserverURLValid = await isKeyserverURLValidCallback(); - if (!isKeyserverURLValid) { + const keyserverVersionData = await isKeyserverURLValidCallback(); + if (!keyserverVersionData) { setShowErrorMessage(true); return; } @@ -57,7 +57,7 @@ dispatch({ type: addKeyserverActionType, payload: { - keyserverAdminUserID: currentUserID, + keyserverAdminUserID: keyserverVersionData.ownerID, newKeyserverInfo, }, });