Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32229620
D11809.1765215571.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D11809.1765215571.diff
View Options
diff --git a/native/community-settings/tag-farcaster-channel/tag-farcaster-channel.react.js b/native/community-settings/tag-farcaster-channel/tag-farcaster-channel.react.js
--- a/native/community-settings/tag-farcaster-channel/tag-farcaster-channel.react.js
+++ b/native/community-settings/tag-farcaster-channel/tag-farcaster-channel.react.js
@@ -22,6 +22,10 @@
import { useSelector } from '../../redux/redux-utils.js';
import { useStyles, useColors } from '../../themes/colors.js';
+const tagFarcasterErrorMessages: { +[string]: string } = {
+ already_in_use: 'This Farcaster channel is already tagged to a community.',
+};
+
export type TagFarcasterChannelParams = {
+communityID: string,
};
@@ -50,6 +54,8 @@
$ReadOnlyArray<FarcasterChannel>,
>([]);
+ const [error, setError] = React.useState<?string>(null);
+
const neynarClientContext = React.useContext(NeynarClientContext);
invariant(neynarClientContext, 'NeynarClientContext is missing');
@@ -79,6 +85,7 @@
return;
}
+ setError(null);
setSelectedChannel(channelOptions[selectedIndex]);
},
[channelOptions],
@@ -129,7 +136,7 @@
farcasterChannelID: selectedChannel.id,
});
} catch (e) {
- console.log('error', e); // TODO: Improve error handling
+ setError(e.message);
throw e;
}
}, [communityID, createOrUpdateFarcasterChannelTag, selectedChannel]);
@@ -146,6 +153,18 @@
[styles.sectionContainer, styles.touchableSectionContainer],
);
+ const errorMessage = React.useMemo(() => {
+ if (!error) {
+ return null;
+ }
+
+ return (
+ <Text style={styles.error}>
+ {tagFarcasterErrorMessages[error] ?? 'Unknown error.'}
+ </Text>
+ );
+ }, [error, styles.error]);
+
const channelSelectionTextContent = selectedChannel?.name
? selectedChannel.name
: 'No Farcaster channel tagged';
@@ -172,6 +191,7 @@
color={colors.panelForegroundSecondaryLabel}
/>
</TouchableOpacity>
+ <View style={styles.errorContainer}>{errorMessage}</View>
<RegistrationButton
onPress={onPressTag}
label="Tag channel"
@@ -183,10 +203,12 @@
styles.sectionContainer,
styles.sectionText,
styles.sectionHeaderText,
+ styles.errorContainer,
channelSelectionStyles,
onPressSelectChannel,
channelSelectionTextContent,
colors.panelForegroundSecondaryLabel,
+ errorMessage,
onPressTag,
buttonVariant,
],
@@ -218,6 +240,16 @@
justifyContent: 'space-between',
alignItems: 'center',
},
+ errorContainer: {
+ height: 18,
+ },
+ error: {
+ fontSize: 12,
+ fontWeight: '400',
+ lineHeight: 18,
+ textAlign: 'center',
+ color: 'redText',
+ },
};
export default TagFarcasterChannel;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 8, 5:39 PM (10 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5849648
Default Alt Text
D11809.1765215571.diff (2 KB)
Attached To
Mode
D11809: [native] show error message for tag farcaster channel errors
Attached
Detach File
Event Timeline
Log In to Comment