adjust redirect
This commit is contained in:
@@ -8,6 +8,7 @@ import {useNavigation} from '@react-navigation/native'
|
||||
import {NativeStackScreenProps} from '@react-navigation/native-stack'
|
||||
import {useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
import {logger} from '#/logger'
|
||||
import {useDeleteStarterPackMutation} from '#/state/queries/starter-packs'
|
||||
import {HITSLOP_20} from 'lib/constants'
|
||||
import {makeProfileLink, makeStarterPackLink} from 'lib/routes/links'
|
||||
@@ -262,25 +263,34 @@ function OverflowMenu({
|
||||
const deleteDialogControl = useDialogControl()
|
||||
const navigation = useNavigation<NavigationProp>()
|
||||
const {
|
||||
mutateAsync: deleteStarterPack,
|
||||
mutate: deleteStarterPack,
|
||||
isPending: isDeletePending,
|
||||
error: deleteError,
|
||||
} = useDeleteStarterPackMutation()
|
||||
} = useDeleteStarterPackMutation({
|
||||
onSuccess: () => {
|
||||
logEvent('starterPack:delete', {})
|
||||
deleteDialogControl.close(() => {
|
||||
if (navigation.canGoBack()) {
|
||||
navigation.popToTop()
|
||||
} else {
|
||||
navigation.navigate('Home')
|
||||
}
|
||||
})
|
||||
},
|
||||
onError: e => {
|
||||
logger.error('Failed to delete starter pack', {safeMessage: e})
|
||||
},
|
||||
})
|
||||
|
||||
const isOwn = starterPack.creator.did === currentAccount?.did
|
||||
|
||||
const onDeleteStarterPack = async () => {
|
||||
await deleteStarterPack({
|
||||
deleteStarterPack({
|
||||
rkey: routeParams.rkey,
|
||||
// TODO need to fix types
|
||||
listUri: starterPack.list!.uri,
|
||||
})
|
||||
|
||||
logEvent('starterPack:delete', {})
|
||||
|
||||
deleteDialogControl.close(() => {
|
||||
navigation.popToTop()
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -246,7 +246,13 @@ export function useEditStarterPackMutation({
|
||||
})
|
||||
}
|
||||
|
||||
export function useDeleteStarterPackMutation() {
|
||||
export function useDeleteStarterPackMutation({
|
||||
onSuccess,
|
||||
onError,
|
||||
}: {
|
||||
onSuccess: () => void
|
||||
onError: (error: Error) => void
|
||||
}) {
|
||||
const agent = useAgent()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
@@ -277,6 +283,10 @@ export function useDeleteStarterPackMutation() {
|
||||
did: agent.session!.did,
|
||||
rkey,
|
||||
})
|
||||
onSuccess()
|
||||
},
|
||||
onError: async error => {
|
||||
onError(error)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user