diff --git a/native/account/registration/keyserver-selection.react.js b/native/account/registration/keyserver-selection.react.js
--- a/native/account/registration/keyserver-selection.react.js
+++ b/native/account/registration/keyserver-selection.react.js
@@ -2,7 +2,7 @@
import invariant from 'invariant';
import * as React from 'react';
-import { Text } from 'react-native';
+import { Text, View } from 'react-native';
import {
getVersion,
@@ -47,6 +47,8 @@
getVersionActionTypes,
);
+type KeyserverSelectionError = 'cant_reach_keyserver';
+
type Props = {
+navigation: RegistrationNavigationProp<'KeyserverSelection'>,
+route: NavigationRoute<'KeyserverSelection'>,
@@ -69,21 +71,30 @@
initialSelection = 'custom';
}
+ const [error, setError] = React.useState();
+
const [currentSelection, setCurrentSelection] =
React.useState(initialSelection);
const selectAshoat = React.useCallback(() => {
setCurrentSelection('ashoat');
customKeyserverTextInputRef.current?.blur();
- }, []);
+ if (currentSelection !== 'ashoat') {
+ setError(undefined);
+ }
+ }, [currentSelection]);
const customKeyserverEmpty = !customKeyserver;
const selectCustom = React.useCallback(() => {
setCurrentSelection('custom');
if (customKeyserverEmpty) {
customKeyserverTextInputRef.current?.focus();
}
- }, [customKeyserverEmpty]);
+ if (currentSelection !== 'custom') {
+ setError(undefined);
+ }
+ }, [customKeyserverEmpty, currentSelection]);
const onCustomKeyserverFocus = React.useCallback(() => {
setCurrentSelection('custom');
+ setError(undefined);
}, []);
let keyserverURL;
@@ -111,6 +122,7 @@
const { navigate } = props.navigation;
const { coolOrNerdMode } = props.route.params.userSelections;
const onSubmit = React.useCallback(async () => {
+ setError(undefined);
if (!keyserverURL) {
return;
}
@@ -119,7 +131,12 @@
dispatchActionPromise(getVersionActionTypes, getVersionPromise);
// We don't care about the result; just need to make sure this doesn't throw
- await getVersionPromise;
+ try {
+ await getVersionPromise;
+ } catch {
+ setError('cant_reach_keyserver');
+ return;
+ }
setCachedSelections(oldUserSelections => ({
...oldUserSelections,
@@ -139,6 +156,13 @@
]);
const styles = useStyles(unboundStyles);
+ let errorText;
+ if (error === 'cant_reach_keyserver') {
+ errorText = (
+ Can’t reach that keyserver :(
+ );
+ }
+
const colors = useColors();
return (
@@ -188,6 +212,7 @@
ref={customKeyserverTextInputRef}
/>
+ {errorText}