mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Continue refine remote logic #638
This commit is contained in:
@ -1,19 +1,13 @@
|
||||
import { InfiniteData } from '@tanstack/react-query'
|
||||
import queryClient from '@utils/queryHooks'
|
||||
import { queryClient } from '@utils/queryHooks'
|
||||
import { MutationVarsTimelineDeleteItem } from '../timeline'
|
||||
|
||||
const deleteItem = ({
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
id
|
||||
}: MutationVarsTimelineDeleteItem) => {
|
||||
const deleteItem = ({ queryKey, rootQueryKey, id }: MutationVarsTimelineDeleteItem) => {
|
||||
queryKey &&
|
||||
queryClient.setQueryData<InfiniteData<any> | undefined>(queryKey, old => {
|
||||
if (old) {
|
||||
old.pages = old.pages.map(page => {
|
||||
page.body = page.body.filter(
|
||||
(item: Mastodon.Status) => item.id !== id
|
||||
)
|
||||
page.body = page.body.filter((item: Mastodon.Status) => item.id !== id)
|
||||
return page
|
||||
})
|
||||
return old
|
||||
@ -21,20 +15,15 @@ const deleteItem = ({
|
||||
})
|
||||
|
||||
rootQueryKey &&
|
||||
queryClient.setQueryData<InfiniteData<any> | undefined>(
|
||||
rootQueryKey,
|
||||
old => {
|
||||
if (old) {
|
||||
old.pages = old.pages.map(page => {
|
||||
page.body = page.body.filter(
|
||||
(item: Mastodon.Status) => item.id !== id
|
||||
)
|
||||
return page
|
||||
})
|
||||
return old
|
||||
}
|
||||
queryClient.setQueryData<InfiniteData<any> | undefined>(rootQueryKey, old => {
|
||||
if (old) {
|
||||
old.pages = old.pages.map(page => {
|
||||
page.body = page.body.filter((item: Mastodon.Status) => item.id !== id)
|
||||
return page
|
||||
})
|
||||
return old
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export default deleteItem
|
||||
|
Reference in New Issue
Block a user