Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3305160
D11866.id39759.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.id39759.diff
View Options
diff --git a/native/community-settings/tag-farcaster-channel/tag-unfollowed-farcaster-channel.react.js b/native/community-settings/tag-farcaster-channel/tag-unfollowed-farcaster-channel.react.js
--- a/native/community-settings/tag-farcaster-channel/tag-unfollowed-farcaster-channel.react.js
+++ b/native/community-settings/tag-farcaster-channel/tag-unfollowed-farcaster-channel.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 SubmitButton from '../../components/submit-button.react.js';
import TextInput from '../../components/text-input.react.js';
@@ -18,17 +26,66 @@
+route: NavigationRoute<'TagUnfollowedFarcasterChannel'>,
};
-// eslint-disable-next-line no-unused-vars
function TagUnfollowedFarcasterChannel(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, 12:24 PM (21 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2539335
Default Alt Text
D11866.id39759.diff (2 KB)
Attached To
Mode
D11866: [native] implement onPressTagChannel for TagUnfollowedFarcasterChannel
Attached
Detach File
Event Timeline
Log In to Comment