MCPcopy Create free account
hub / github.com/block/buzz / useCreateForumReplyMutation

Function useCreateForumReplyMutation

desktop/src/features/forum/hooks.ts:129–168  ·  view source on GitHub ↗
(channel: Channel | null)

Source from the content-addressed store, hash-verified

127}
128
129export function useCreateForumReplyMutation(channel: Channel | null) {
130 const queryClient = useQueryClient();
131
132 return useMutation({
133 mutationFn: async ({
134 content,
135 parentEventId,
136 mentionPubkeys,
137 mediaTags,
138 }: {
139 content: string;
140 parentEventId: string;
141 mentionPubkeys?: string[];
142 mediaTags?: string[][];
143 }) => {
144 if (!channel) {
145 throw new Error("No channel selected.");
146 }
147
148 return sendChannelMessage(
149 channel.id,
150 content,
151 parentEventId,
152 mediaTags,
153 mentionPubkeys,
154 KIND_FORUM_COMMENT,
155 );
156 },
157 onSuccess: (_data, variables) => {
158 if (channel) {
159 void queryClient.invalidateQueries({
160 queryKey: forumThreadQueryKey(channel.id, variables.parentEventId),
161 });
162 void queryClient.invalidateQueries({
163 queryKey: forumPostsQueryKey(channel.id),
164 });
165 }
166 },
167 });
168}

Callers 1

ForumViewFunction · 0.90

Calls 3

sendChannelMessageFunction · 0.90
forumThreadQueryKeyFunction · 0.85
forumPostsQueryKeyFunction · 0.85

Tested by

no test coverage detected