Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3178481
D12057.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D12057.id.diff
View Options
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
@@ -13,7 +13,7 @@
function useIsKeyserverURLValid(
keyserverURL?: string,
-): () => Promise<?VersionResponse> {
+): () => Promise<VersionResponse> {
const urlsToIDs: { +[keyserverID: string]: ?string } =
useSelector(urlsToIDsSelector);
@@ -53,18 +53,14 @@
return React.useCallback(async () => {
if (!keyserverURL) {
- return null;
+ throw new Error('isKeyserverURLValid called with empty URL');
}
const getVersionPromise = getVersionCall();
void dispatchActionPromise(getVersionActionTypes, getVersionPromise);
- try {
- const { versionResponses } = await getVersionPromise;
- return versionResponses[Object.keys(versionResponses)[0]];
- } catch (e) {
- return null;
- }
+ const { versionResponses } = await getVersionPromise;
+ return versionResponses[Object.keys(versionResponses)[0]];
}, [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
@@ -8,6 +8,7 @@
import { useIsKeyserverURLValid } from 'lib/shared/keyserver-utils.js';
import type { KeyserverInfo } from 'lib/types/keyserver-types.js';
import { defaultKeyserverInfo } from 'lib/types/keyserver-types.js';
+import { getMessageForException } from 'lib/utils/errors.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
import type { ProfileNavigationProp } from './profile.react.js';
@@ -16,15 +17,20 @@
import type { NavigationRoute } from '../navigation/route-names.js';
import { useSelector } from '../redux/redux-utils.js';
import { useStyles, useColors } from '../themes/colors.js';
+import { AppOutOfDateAlertDetails } from '../utils/alert-messages.js';
import { useStaffCanSee } from '../utils/staff-utils.js';
type KeyserverCheckStatus =
| { +status: 'inactive' }
| { +status: 'loading' }
- | { +status: 'error' };
+ | { +status: 'error', +error: 'generic' | 'client_version_unsupported' };
const keyserverCheckStatusInactive = { status: 'inactive' };
const keyserverCheckStatusLoading = { status: 'loading' };
-const keyserverCheckStatusError = { status: 'error' };
+const keyserverCheckStatusGenericError = { status: 'error', error: 'generic' };
+const keyserverCheckStatusVersionError = {
+ status: 'error',
+ error: 'client_version_unsupported',
+};
type Props = {
+navigation: ProfileNavigationProp<'AddKeyserver'>,
@@ -59,9 +65,16 @@
}
setStatus(keyserverCheckStatusLoading);
- const keyserverVersionData = await isKeyserverURLValidCallback();
- if (!keyserverVersionData) {
- setStatus(keyserverCheckStatusError);
+ let keyserverVersionData;
+ try {
+ keyserverVersionData = await isKeyserverURLValidCallback();
+ } catch (e) {
+ const message = getMessageForException(e);
+ if (message === 'client_version_unsupported') {
+ setStatus(keyserverCheckStatusVersionError);
+ } else {
+ setStatus(keyserverCheckStatusGenericError);
+ }
return;
}
setStatus(keyserverCheckStatusInactive);
@@ -97,19 +110,20 @@
[],
);
- const showErrorMessage = status.status === 'error';
+ const { error } = status;
const errorMessage = React.useMemo(() => {
- if (!showErrorMessage) {
+ let errorText;
+ if (error === 'client_version_unsupported') {
+ errorText = AppOutOfDateAlertDetails.message;
+ } else if (error) {
+ errorText =
+ 'Cannot connect to keyserver. Please check the URL or your ' +
+ 'and try again.';
+ } else {
return null;
}
-
- return (
- <Text style={styles.errorMessage}>
- Cannot connect to keyserver. Please check the URL or your connection and
- try again.
- </Text>
- );
- }, [showErrorMessage, styles.errorMessage]);
+ return <Text style={styles.errorMessage}>{errorText}</Text>;
+ }, [error, styles.errorMessage]);
return (
<View style={styles.container}>
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
@@ -7,22 +7,28 @@
import { useIsKeyserverURLValid } from 'lib/shared/keyserver-utils.js';
import type { KeyserverInfo } from 'lib/types/keyserver-types.js';
import { defaultKeyserverInfo } from 'lib/types/keyserver-types.js';
+import { getMessageForException } from 'lib/utils/errors.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
import css from './add-keyserver-modal.css';
import Button, { buttonThemes } from '../../components/button.react.js';
import { useSelector } from '../../redux/redux-utils.js';
import { useStaffCanSee } from '../../utils/staff-utils.js';
+import { getVersionUnsupportedError } from '../../utils/version-utils.js';
import Input from '../input.react.js';
import Modal from '../modal.react.js';
type KeyserverCheckStatus =
| { +status: 'inactive' }
| { +status: 'loading' }
- | { +status: 'error' };
+ | { +status: 'error', +error: 'generic' | 'client_version_unsupported' };
const keyserverCheckStatusInactive = { status: 'inactive' };
const keyserverCheckStatusLoading = { status: 'loading' };
-const keyserverCheckStatusError = { status: 'error' };
+const keyserverCheckStatusGenericError = { status: 'error', error: 'generic' };
+const keyserverCheckStatusVersionError = {
+ status: 'error',
+ error: 'client_version_unsupported',
+};
function AddKeyserverModal(): React.Node {
const { popModal } = useModalContext();
@@ -55,9 +61,16 @@
}
setStatus(keyserverCheckStatusLoading);
- const keyserverVersionData = await isKeyserverURLValidCallback();
- if (!keyserverVersionData) {
- setStatus(keyserverCheckStatusError);
+ let keyserverVersionData;
+ try {
+ keyserverVersionData = await isKeyserverURLValidCallback();
+ } catch (e) {
+ const message = getMessageForException(e);
+ if (message === 'client_version_unsupported') {
+ setStatus(keyserverCheckStatusVersionError);
+ } else {
+ setStatus(keyserverCheckStatusGenericError);
+ }
return;
}
setStatus(keyserverCheckStatusInactive);
@@ -81,16 +94,18 @@
isKeyserverURLValidCallback,
]);
- const showErrorMessage = status.status === 'error';
+ const { error } = status;
const errorMessage = React.useMemo(() => {
let errorText;
- if (showErrorMessage) {
+ if (error === 'client_version_unsupported') {
+ errorText = getVersionUnsupportedError();
+ } else if (error) {
errorText =
'Cannot connect to keyserver. Please check the URL or your ' +
'connection and try again.';
}
return <div className={css.errorMessage}>{errorText}</div>;
- }, [showErrorMessage]);
+ }, [error]);
const buttonDisabled = !keyserverURL || status.status === 'loading';
const addKeyserverButton = React.useMemo(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 1:56 AM (14 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2446656
Default Alt Text
D12057.id.diff (7 KB)
Attached To
Mode
D12057: [lib][native][web] Error text for when adding keyserver fails due to unsupported version
Attached
Detach File
Event Timeline
Log In to Comment