(channel: Channel | null)
| 127 | } |
| 128 | |
| 129 | export 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 | } |
no test coverage detected