MCPcopy Create free account
hub / github.com/CommE2E/comm / useCreateFarcasterChannelTag

Function useCreateFarcasterChannelTag

lib/shared/community-utils.js:57–113  ·  view source on GitHub ↗
(
  commCommunityID: string,
  setError: SetState<?string>,
  onSuccessCallback?: () => mixed,
)

Source from the content-addressed store, hash-verified

55const createOrUpdateFarcasterChannelTagStatusSelector =
56 createLoadingStatusSelector(createOrUpdateFarcasterChannelTagActionTypes);
57function useCreateFarcasterChannelTag(
58 commCommunityID: string,
59 setError: SetState<?string>,
60 onSuccessCallback?: () => mixed,
61): {
62 +createTag: (farcasterChannelID: string) => mixed,
63 +isLoading: boolean,
64} {
65 const dispatchActionPromise = useDispatchActionPromise();
66
67 const createOrUpdateFarcasterChannelTag =
68 useCreateOrUpdateFarcasterChannelTag();
69
70 const createCreateOrUpdateActionPromise = React.useCallback(
71 async (farcasterChannelID: string) => {
72 try {
73 const res = await createOrUpdateFarcasterChannelTag({
74 commCommunityID,
75 farcasterChannelID,
76 });
77
78 onSuccessCallback?.();
79
80 return res;
81 } catch (e) {
82 setError(e.message);
83 throw e;
84 }
85 },
86 [
87 commCommunityID,
88 createOrUpdateFarcasterChannelTag,
89 onSuccessCallback,
90 setError,
91 ],
92 );
93
94 const createTag = React.useCallback(
95 (farcasterChannelID: string) => {
96 void dispatchActionPromise(
97 createOrUpdateFarcasterChannelTagActionTypes,
98 createCreateOrUpdateActionPromise(farcasterChannelID),
99 );
100 },
101 [createCreateOrUpdateActionPromise, dispatchActionPromise],
102 );
103
104 const createOrUpdateFarcasterChannelTagStatus = useSelector(
105 createOrUpdateFarcasterChannelTagStatusSelector,
106 );
107 const isLoading = createOrUpdateFarcasterChannelTagStatus === 'loading';
108
109 return {
110 createTag,
111 isLoading,
112 };
113}
114

Calls 6

useDispatchActionPromiseFunction · 0.90
useSelectorFunction · 0.90
onSuccessCallbackFunction · 0.85
dispatchActionPromiseFunction · 0.85

Tested by

no test coverage detected