add delete starterpack mutation
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
import {AppBskyGraphGetStarterPack} from '@atproto/api'
|
import {AppBskyGraphGetStarterPack} from '@atproto/api'
|
||||||
|
import {useMutation} from '@tanstack/react-query'
|
||||||
import {useQuery} from 'react-query'
|
import {useQuery} from 'react-query'
|
||||||
|
|
||||||
import {STALE} from 'state/queries/index'
|
import {STALE} from 'state/queries/index'
|
||||||
import {useAgent} from 'state/session'
|
import {useAgent, useSession} from 'state/session'
|
||||||
|
|
||||||
const RQKEY_ROOT = 'starter-pack'
|
const RQKEY_ROOT = 'starter-pack'
|
||||||
|
|
||||||
@@ -20,3 +21,25 @@ export function useStarterPackQuery({id}: {id: string}) {
|
|||||||
staleTime: STALE.MINUTES.FIVE,
|
staleTime: STALE.MINUTES.FIVE,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useDeleteStarterPackMutation({
|
||||||
|
onError,
|
||||||
|
onSuccess,
|
||||||
|
}: {
|
||||||
|
onError: () => void
|
||||||
|
onSuccess: () => void
|
||||||
|
}) {
|
||||||
|
const agent = useAgent()
|
||||||
|
const {currentAccount} = useSession()
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async (rkey: string) => {
|
||||||
|
await agent.app.bsky.graph.starterpack.delete({
|
||||||
|
repo: currentAccount!.did,
|
||||||
|
rkey,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onError,
|
||||||
|
onSuccess,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user