mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Try to fix #16
This commit is contained in:
@ -1,24 +1,45 @@
|
||||
import { InfiniteData, QueryClient } from 'react-query'
|
||||
import { QueryKeyTimeline, TimelineData } from '../timeline'
|
||||
import { MutationVarsTimelineDeleteItem } from '../timeline'
|
||||
|
||||
const deleteItem = ({
|
||||
queryClient,
|
||||
queryKey,
|
||||
rootQueryKey,
|
||||
id
|
||||
}: {
|
||||
queryClient: QueryClient
|
||||
queryKey: QueryKeyTimeline
|
||||
id: Mastodon.Status['id']
|
||||
queryKey?: MutationVarsTimelineDeleteItem['queryKey']
|
||||
rootQueryKey?: MutationVarsTimelineDeleteItem['rootQueryKey']
|
||||
id: MutationVarsTimelineDeleteItem['id']
|
||||
}) => {
|
||||
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)
|
||||
return page
|
||||
})
|
||||
return old
|
||||
}
|
||||
})
|
||||
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
|
||||
)
|
||||
return page
|
||||
})
|
||||
return old
|
||||
}
|
||||
})
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export default deleteItem
|
||||
|
Reference in New Issue
Block a user