Skip to content

Commit

Permalink
feat: subscription patch api
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed May 14, 2024
1 parent 6aa257c commit f51cd58
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/renderer/src/components/follow/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,21 @@ export function FollowDialog({
const followMutation = useMutation({
mutationFn: async (values: z.infer<typeof formSchema>) =>
apiFetch("/subscriptions", {
method: "POST",
method: isSubscribed ? "PATCH" : "POST",
body: {
url: feed.feeds.url,
view: parseInt(values.view),
category: values.category,
isPrivate: values.isPrivate,
...(isSubscribed && { feedId: feed.feeds.id }),
},
}),
onSuccess: (_, variables) => {
if (isSubscribed && variables.view !== feed.view + "") {
queryClient.invalidateQueries({
queryKey: ["subscriptions", feed.view],
})
}
queryClient.invalidateQueries({
queryKey: ["subscriptions", parseInt(variables.view)],
})
Expand Down

0 comments on commit f51cd58

Please sign in to comment.