Page MenuHomePhabricator

D11873.diff
No OneTemporary

D11873.diff

diff --git a/native/account/registration/connect-farcaster.react.js b/native/account/registration/connect-farcaster.react.js
--- a/native/account/registration/connect-farcaster.react.js
+++ b/native/account/registration/connect-farcaster.react.js
@@ -23,6 +23,10 @@
ConnectEthereumRouteName,
AvatarSelectionRouteName,
} from '../../navigation/route-names.js';
+import {
+ getFarcasterAccountAlreadyLinkedAlertDetails,
+ type AlertDetails,
+} from '../../utils/alert-messages.js';
import { useStaffCanSee } from '../../utils/staff-utils.js';
export type ConnectFarcasterParams = ?{
@@ -110,10 +114,7 @@
identityServiceClient?.identityClient.getFarcasterUsers;
invariant(getFarcasterUsers, 'Could not get getFarcasterUsers');
- const [queuedAlert, setQueuedAlert] = React.useState<?{
- +title: string,
- +body: string,
- }>();
+ const [queuedAlert, setQueuedAlert] = React.useState<?AlertDetails>();
const onSuccess = React.useCallback(
async (fid: string) => {
@@ -121,10 +122,11 @@
const commFCUsers = await getFarcasterUsers([fid]);
if (commFCUsers.length > 0 && commFCUsers[0].farcasterID === fid) {
const commUsername = commFCUsers[0].username;
- setQueuedAlert({
- title: 'Farcaster account already linked',
- body: `That Farcaster account is already linked to ${commUsername}`,
- });
+
+ const alert =
+ getFarcasterAccountAlreadyLinkedAlertDetails(commUsername);
+
+ setQueuedAlert(alert);
setWebViewState('closed');
} else {
goToNextStep(fid);
@@ -136,7 +138,7 @@
} catch (e) {
setQueuedAlert({
title: 'Failed to query Comm',
- body:
+ message:
'We failed to query Comm to see if that Farcaster account is ' +
'already linked',
});
@@ -151,7 +153,7 @@
if (!queuedAlert || !isAppForegrounded) {
return;
}
- Alert.alert(queuedAlert.title, queuedAlert.body);
+ Alert.alert(queuedAlert.title, queuedAlert.message);
setQueuedAlert(null);
}, [queuedAlert, isAppForegrounded]);
diff --git a/native/utils/alert-messages.js b/native/utils/alert-messages.js
--- a/native/utils/alert-messages.js
+++ b/native/utils/alert-messages.js
@@ -2,7 +2,7 @@
import { Platform } from 'react-native';
-type AlertDetails = {
+export type AlertDetails = {
+title: string,
+message: string,
};
@@ -12,31 +12,49 @@
android: 'Play Store',
});
-export const AppOutOfDateAlertDetails: AlertDetails = {
+const AppOutOfDateAlertDetails: AlertDetails = {
title: 'App out of date',
message:
'Your app version is pretty old, and the server doesn’t know how ' +
`to speak to it anymore. Please use the ${platformStore} to update!`,
};
-export const UsernameReservedAlertDetails: AlertDetails = {
+const UsernameReservedAlertDetails: AlertDetails = {
title: 'Username reserved',
message:
'This username is currently reserved. Please contact support@' +
'comm.app if you would like to claim this account.',
};
-export const UsernameTakenAlertDetails: AlertDetails = {
+const UsernameTakenAlertDetails: AlertDetails = {
title: 'Username taken',
message: 'An account with that username already exists',
};
-export const UserNotFoundAlertDetails: AlertDetails = {
+const UserNotFoundAlertDetails: AlertDetails = {
title: 'Incorrect username or password',
message: "Either that user doesn't exist, or the password is incorrect",
};
-export const UnknownErrorAlertDetails: AlertDetails = {
+const UnknownErrorAlertDetails: AlertDetails = {
title: 'Unknown error',
message: 'Uhh... try again?',
};
+
+const getFarcasterAccountAlreadyLinkedAlertDetails = (
+ commUsername: ?string,
+): AlertDetails => ({
+ title: 'Farcaster account already linked',
+ message: `That Farcaster account is already linked to ${
+ commUsername ? commUsername : 'another account'
+ }`,
+});
+
+export {
+ AppOutOfDateAlertDetails,
+ UsernameReservedAlertDetails,
+ UsernameTakenAlertDetails,
+ UserNotFoundAlertDetails,
+ UnknownErrorAlertDetails,
+ getFarcasterAccountAlreadyLinkedAlertDetails,
+};

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 2, 4:14 PM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2608169
Default Alt Text
D11873.diff (4 KB)

Event Timeline