update-reaction-query-fix

This commit is contained in:
Untone 2024-02-16 19:58:24 +03:00
parent 2763bb4eef
commit b295ba0dbf
3 changed files with 7 additions and 6 deletions

View File

@ -96,7 +96,8 @@ export const Comment = (props: Props) => {
const handleUpdate = async (value) => { const handleUpdate = async (value) => {
setLoading(true) setLoading(true)
try { try {
await updateReaction(props.comment.id, { await updateReaction({
id: props.comment.id,
kind: ReactionKind.Comment, kind: ReactionKind.Comment,
body: value, body: value,
shout: props.comment.shout.id, shout: props.comment.shout.id,

View File

@ -18,7 +18,7 @@ type ReactionsContextType = {
offset?: number offset?: number
}) => Promise<Reaction[]> }) => Promise<Reaction[]>
createReaction: (reaction: ReactionInput) => Promise<void> createReaction: (reaction: ReactionInput) => Promise<void>
updateReaction: (id: number, reaction: ReactionInput) => Promise<void> updateReaction: (reaction: ReactionInput) => Promise<void>
deleteReaction: (id: number) => Promise<void> deleteReaction: (id: number) => Promise<void>
} }
@ -88,8 +88,8 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
} }
} }
const updateReaction = async (id: number, input: ReactionInput): Promise<void> => { const updateReaction = async (input: ReactionInput): Promise<void> => {
const reaction = await apiClient.updateReaction(id, input) const reaction = await apiClient.updateReaction(input)
setReactionEntities(reaction.id, reaction) setReactionEntities(reaction.id, reaction)
} }

View File

@ -183,9 +183,9 @@ export const apiClient = {
console.debug('[graphql.client.core] destroyReaction:', response) console.debug('[graphql.client.core] destroyReaction:', response)
return response.data.delete_reaction.reaction return response.data.delete_reaction.reaction
}, },
updateReaction: async (id: number, input: ReactionInput) => { updateReaction: async (reaction: ReactionInput) => {
const response = await apiClient.private const response = await apiClient.private
.mutation(reactionUpdate, { id: id, reaction: input }) .mutation(reactionUpdate, { reaction })
.toPromise() .toPromise()
console.debug('[graphql.client.core] updateReaction:', response) console.debug('[graphql.client.core] updateReaction:', response)
return response.data.update_reaction.reaction return response.data.update_reaction.reaction