(channel: Channel | null)
| 43 | } |
| 44 | |
| 45 | export 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 | |
| 81 | export function useDeleteForumPostMutation(channel: Channel | null) { |
| 82 | const queryClient = useQueryClient(); |
no test coverage detected