delete-reaction-fix
This commit is contained in:
parent
ce66874089
commit
5b97ea3746
|
@ -129,7 +129,7 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
|
|||
const updateShout = async (formToUpdate: ShoutForm, { publish }: { publish: boolean }) => {
|
||||
if (!formToUpdate.shoutId) {
|
||||
console.error(formToUpdate)
|
||||
return {"error": "not enought data"}
|
||||
return { error: 'not enought data' }
|
||||
}
|
||||
return await apiClient.updateArticle({
|
||||
shout_id: formToUpdate.shoutId,
|
||||
|
|
|
@ -5,6 +5,8 @@ import { createStore, reconcile } from 'solid-js/store'
|
|||
|
||||
import { apiClient } from '../graphql/client/core'
|
||||
import { Reaction, ReactionBy, ReactionInput, ReactionKind } from '../graphql/schema/core.gen'
|
||||
import { useLocalize } from './localize'
|
||||
import { useSnackbar } from './snackbar'
|
||||
|
||||
type ReactionsContextType = {
|
||||
reactionEntities: Record<number, Reaction>
|
||||
|
@ -30,6 +32,8 @@ export function useReactions() {
|
|||
|
||||
export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
||||
const [reactionEntities, setReactionEntities] = createStore<Record<number, Reaction>>({})
|
||||
const { t } = useLocalize()
|
||||
const { showSnackbar } = useSnackbar()
|
||||
|
||||
const loadReactionsBy = async ({
|
||||
by,
|
||||
|
@ -81,7 +85,10 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
|||
|
||||
const deleteReaction = async (reaction_id: number): Promise<void> => {
|
||||
if (reaction_id) {
|
||||
await apiClient.destroyReaction(reaction_id)
|
||||
const { error } = await apiClient.destroyReaction(reaction_id)
|
||||
if (error) {
|
||||
await showSnackbar({ type: 'error', body: t(error) })
|
||||
}
|
||||
setReactionEntities({
|
||||
[reaction_id]: undefined,
|
||||
})
|
||||
|
|
|
@ -28,9 +28,9 @@ import reactionDestroy from '../mutation/core/reaction-destroy'
|
|||
import reactionUpdate from '../mutation/core/reaction-update'
|
||||
import unfollowMutation from '../mutation/core/unfollow'
|
||||
import shoutLoad from '../query/core/article-load'
|
||||
import getMyShout from '../query/core/article-my'
|
||||
import shoutsLoadBy from '../query/core/articles-load-by'
|
||||
import draftsLoad from '../query/core/articles-load-drafts'
|
||||
import getMyShout from '../query/core/article-my'
|
||||
import myFeed from '../query/core/articles-load-feed'
|
||||
import loadShoutsTopRandom from '../query/core/articles-load-random-top'
|
||||
import articlesLoadRandomTopic from '../query/core/articles-load-random-topic'
|
||||
|
|
Loading…
Reference in New Issue
Block a user