Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3303116
D11866.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11866.diff
View Options
diff --git a/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js b/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js
--- a/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js
+++ b/native/community-settings/tag-farcaster-channel/tag-farcaster-channel-by-name.react.js
@@ -1,8 +1,16 @@
// @flow
+import invariant from 'invariant';
import * as React from 'react';
import { View, Text } from 'react-native';
+import {
+ createOrUpdateFarcasterChannelTagActionTypes,
+ useCreateOrUpdateFarcasterChannelTag,
+} from 'lib/actions/community-actions.js';
+import { NeynarClientContext } from 'lib/components/neynar-client-provider.react.js';
+import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
+
import type { TagFarcasterChannelNavigationProp } from './tag-farcaster-channel-navigator.react.js';
import RegistrationButton from '../../account/registration/registration-button.react.js';
import TextInput from '../../components/text-input.react.js';
@@ -18,17 +26,66 @@
+route: NavigationRoute<'TagFarcasterChannelByName'>,
};
-// eslint-disable-next-line no-unused-vars
function TagFarcasterChannelByName(prop: Props): React.Node {
+ const { navigation, route } = prop;
+
+ const { goBack } = navigation;
+ const { communityID } = route.params;
+
const styles = useStyles(unboundStyles);
const colors = useColors();
const [channelSelectionText, setChannelSelectionText] =
React.useState<string>('');
+ const neynarClientContext = React.useContext(NeynarClientContext);
+ invariant(neynarClientContext, 'NeynarClientContext is missing');
+
+ const dispatchActionPromise = useDispatchActionPromise();
+
+ const createOrUpdateFarcasterChannelTag =
+ useCreateOrUpdateFarcasterChannelTag();
+
+ const createCreateOrUpdateActionPromise = React.useCallback(
+ async (channelID: string) => {
+ try {
+ return await createOrUpdateFarcasterChannelTag({
+ commCommunityID: communityID,
+ farcasterChannelID: channelID,
+ });
+ } catch (e) {
+ // TODO: Improve error handling
+ console.log(e.message);
+ throw e;
+ }
+ },
+ [communityID, createOrUpdateFarcasterChannelTag],
+ );
+
const onPressTagChannel = React.useCallback(async () => {
- // TODO
- }, []);
+ const channelInfo =
+ await neynarClientContext.client.fetchFarcasterChannelByName(
+ channelSelectionText,
+ );
+
+ if (!channelInfo) {
+ // TODO: Improve error handling
+ return;
+ }
+
+ await dispatchActionPromise(
+ createOrUpdateFarcasterChannelTagActionTypes,
+ createCreateOrUpdateActionPromise(channelInfo.id),
+ );
+
+ goBack();
+ }, [
+ channelSelectionText,
+ createCreateOrUpdateActionPromise,
+ dispatchActionPromise,
+ goBack,
+ neynarClientContext.client,
+ ]);
const submitButtonVariant =
channelSelectionText.length > 0 ? 'enabled' : 'disabled';
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 19, 10:26 AM (21 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2537721
Default Alt Text
D11866.diff (2 KB)
Attached To
Mode
D11866: [native] implement onPressTagChannel for TagUnfollowedFarcasterChannel
Attached
Detach File
Event Timeline
Log In to Comment