reaction-error-handling
This commit is contained in:
parent
5b97ea3746
commit
e2c98ded5e
|
@ -57,7 +57,8 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const createReaction = async (input: ReactionInput): Promise<void> => {
|
const createReaction = async (input: ReactionInput): Promise<void> => {
|
||||||
const reaction = await apiClient.createReaction(input)
|
const {error, reaction} = await apiClient.createReaction(input)
|
||||||
|
if (error) await showSnackbar({type: 'error', body: t(error)})
|
||||||
if (!reaction) return
|
if (!reaction) return
|
||||||
const changes = {
|
const changes = {
|
||||||
[reaction.id]: reaction,
|
[reaction.id]: reaction,
|
||||||
|
@ -96,8 +97,9 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateReaction = async (input: ReactionInput): Promise<Reaction> => {
|
const updateReaction = async (input: ReactionInput): Promise<Reaction> => {
|
||||||
const reaction = await apiClient.updateReaction(input)
|
const {error, reaction} = await apiClient.updateReaction(input)
|
||||||
setReactionEntities(reaction.id, reaction)
|
if (error) await showSnackbar({type: 'error', body: t(error)})
|
||||||
|
if (reaction) setReactionEntities(reaction.id, reaction)
|
||||||
return reaction
|
return reaction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user