diff --git a/src/state/queries/useStarterPackQuery.ts b/src/state/queries/useStarterPackQuery.ts index 57fefd97cb..4635dbe48f 100644 --- a/src/state/queries/useStarterPackQuery.ts +++ b/src/state/queries/useStarterPackQuery.ts @@ -1,8 +1,9 @@ import {AppBskyGraphGetStarterPack} from '@atproto/api' +import {useMutation} from '@tanstack/react-query' import {useQuery} from 'react-query' import {STALE} from 'state/queries/index' -import {useAgent} from 'state/session' +import {useAgent, useSession} from 'state/session' const RQKEY_ROOT = 'starter-pack' @@ -20,3 +21,25 @@ export function useStarterPackQuery({id}: {id: string}) { 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, + }) +}