mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Switch to shared hooks
This commit is contained in:
25
src/utils/queryHooks/timeline/deleteItem.ts
Normal file
25
src/utils/queryHooks/timeline/deleteItem.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { InfiniteData, QueryClient } from 'react-query'
|
||||
import { QueryKeyTimeline } from '../timeline'
|
||||
|
||||
const deleteItem = ({
|
||||
queryClient,
|
||||
queryKey,
|
||||
id
|
||||
}: {
|
||||
queryClient: QueryClient
|
||||
queryKey: QueryKeyTimeline
|
||||
id: Mastodon.Status['id']
|
||||
}) => {
|
||||
queryClient.setQueryData<InfiniteData<Mastodon.Conversation[]> | undefined>(
|
||||
queryKey,
|
||||
old => {
|
||||
if (old) {
|
||||
old.pages = old.pages.map(page => page.filter(item => item.id !== id))
|
||||
}
|
||||
|
||||
return old
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export default deleteItem
|
Reference in New Issue
Block a user