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

Function useCreateForumPostMutation

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

Source from the content-addressed store, hash-verified

43}
44
45export function useCreateForumPostMutation(channel: Channel | null) {
46 const queryClient = useQueryClient();
47
48 return useMutation({
49 mutationFn: async ({
50 content,
51 mentionPubkeys,
52 mediaTags,
53 }: {
54 content: string;
55 mentionPubkeys?: string[];
56 mediaTags?: string[][];
57 }) => {
58 if (!channel) {
59 throw new Error("No channel selected.");
60 }
61
62 return sendChannelMessage(
63 channel.id,
64 content,
65 null,
66 mediaTags,
67 mentionPubkeys,
68 KIND_FORUM_POST,
69 );
70 },
71 onSuccess: () => {
72 if (channel) {
73 void queryClient.invalidateQueries({
74 queryKey: forumPostsQueryKey(channel.id),
75 });
76 }
77 },
78 });
79}
80
81export function useDeleteForumPostMutation(channel: Channel | null) {
82 const queryClient = useQueryClient();

Callers 1

ForumViewFunction · 0.90

Calls 2

sendChannelMessageFunction · 0.90
forumPostsQueryKeyFunction · 0.85

Tested by

no test coverage detected