From b295ba0dbf62be7418497d4355c2ea7d16743fcf Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 16 Feb 2024 19:58:24 +0300 Subject: [PATCH] update-reaction-query-fix --- src/components/Article/Comment/Comment.tsx | 3 ++- src/context/reactions.tsx | 6 +++--- src/graphql/client/core.ts | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/Article/Comment/Comment.tsx b/src/components/Article/Comment/Comment.tsx index 0df0a748..f0d468a2 100644 --- a/src/components/Article/Comment/Comment.tsx +++ b/src/components/Article/Comment/Comment.tsx @@ -96,7 +96,8 @@ export const Comment = (props: Props) => { const handleUpdate = async (value) => { setLoading(true) try { - await updateReaction(props.comment.id, { + await updateReaction({ + id: props.comment.id, kind: ReactionKind.Comment, body: value, shout: props.comment.shout.id, diff --git a/src/context/reactions.tsx b/src/context/reactions.tsx index 48da0594..ae4c7b95 100644 --- a/src/context/reactions.tsx +++ b/src/context/reactions.tsx @@ -18,7 +18,7 @@ type ReactionsContextType = { offset?: number }) => Promise createReaction: (reaction: ReactionInput) => Promise - updateReaction: (id: number, reaction: ReactionInput) => Promise + updateReaction: (reaction: ReactionInput) => Promise deleteReaction: (id: number) => Promise } @@ -88,8 +88,8 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => { } } - const updateReaction = async (id: number, input: ReactionInput): Promise => { - const reaction = await apiClient.updateReaction(id, input) + const updateReaction = async (input: ReactionInput): Promise => { + const reaction = await apiClient.updateReaction(input) setReactionEntities(reaction.id, reaction) } diff --git a/src/graphql/client/core.ts b/src/graphql/client/core.ts index bd6571c1..e83d4872 100644 --- a/src/graphql/client/core.ts +++ b/src/graphql/client/core.ts @@ -183,9 +183,9 @@ export const apiClient = { console.debug('[graphql.client.core] destroyReaction:', response) return response.data.delete_reaction.reaction }, - updateReaction: async (id: number, input: ReactionInput) => { + updateReaction: async (reaction: ReactionInput) => { const response = await apiClient.private - .mutation(reactionUpdate, { id: id, reaction: input }) + .mutation(reactionUpdate, { reaction }) .toPromise() console.debug('[graphql.client.core] updateReaction:', response) return response.data.update_reaction.reaction