remove delete dialog/btn
This commit is contained in:
@@ -35,7 +35,7 @@ import {
|
|||||||
useEditStarterPackMutation,
|
useEditStarterPackMutation,
|
||||||
useStarterPackQuery,
|
useStarterPackQuery,
|
||||||
} from 'state/queries/starter-packs'
|
} from 'state/queries/starter-packs'
|
||||||
import {useAgent, useSession} from 'state/session'
|
import {useSession} from 'state/session'
|
||||||
import {useSetMinimalShellMode} from 'state/shell'
|
import {useSetMinimalShellMode} from 'state/shell'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
import {UserAvatar} from 'view/com/util/UserAvatar'
|
import {UserAvatar} from 'view/com/util/UserAvatar'
|
||||||
@@ -49,7 +49,6 @@ import {Button, ButtonText} from '#/components/Button'
|
|||||||
import {useDialogControl} from '#/components/Dialog'
|
import {useDialogControl} from '#/components/Dialog'
|
||||||
import {ListMaybePlaceholder} from '#/components/Lists'
|
import {ListMaybePlaceholder} from '#/components/Lists'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import * as Prompt from '#/components/Prompt'
|
|
||||||
import {WizardEditListDialog} from '#/components/StarterPack/Wizard/WizardEditListDialog'
|
import {WizardEditListDialog} from '#/components/StarterPack/Wizard/WizardEditListDialog'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {Provider} from './State'
|
import {Provider} from './State'
|
||||||
@@ -141,7 +140,6 @@ function WizardInner({
|
|||||||
const setMinimalShellMode = useSetMinimalShellMode()
|
const setMinimalShellMode = useSetMinimalShellMode()
|
||||||
const {setEnabled} = useKeyboardController()
|
const {setEnabled} = useKeyboardController()
|
||||||
const [state, dispatch] = useWizardState()
|
const [state, dispatch] = useWizardState()
|
||||||
const agent = useAgent()
|
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {data: currentProfile} = useProfileQuery({
|
const {data: currentProfile} = useProfileQuery({
|
||||||
did: currentAccount?.did,
|
did: currentAccount?.did,
|
||||||
@@ -269,31 +267,6 @@ function WizardInner({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteStarterPack = async () => {
|
|
||||||
if (!currentStarterPack || !currentListItems) return
|
|
||||||
|
|
||||||
dispatch({type: 'SetProcessing', processing: true})
|
|
||||||
|
|
||||||
try {
|
|
||||||
await agent.app.bsky.graph.list.delete({
|
|
||||||
repo: currentAccount!.did,
|
|
||||||
// TODO list is required, so shouldn't need this assertion
|
|
||||||
rkey: new AtUri(currentStarterPack.list!.uri).rkey,
|
|
||||||
})
|
|
||||||
await agent.app.bsky.graph.starterpack.delete({
|
|
||||||
repo: currentAccount!.did,
|
|
||||||
rkey: new AtUri(currentStarterPack.uri).rkey,
|
|
||||||
})
|
|
||||||
|
|
||||||
logEvent('starterPack:delete', {})
|
|
||||||
navigation.popToTop()
|
|
||||||
} catch (e) {
|
|
||||||
Toast.show(_(msg`Failed to delete starter pack`))
|
|
||||||
} finally {
|
|
||||||
dispatch({type: 'SetProcessing', processing: false})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const onNext = () => {
|
const onNext = () => {
|
||||||
if (state.currentStep === 'Feeds') {
|
if (state.currentStep === 'Feeds') {
|
||||||
submit()
|
submit()
|
||||||
@@ -352,9 +325,7 @@ function WizardInner({
|
|||||||
<View style={[{width: 65}]} />
|
<View style={[{width: 65}]} />
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Container
|
<Container>
|
||||||
showDeleteBtn={Boolean(currentStarterPack)}
|
|
||||||
deleteStarterPack={deleteStarterPack}>
|
|
||||||
{state.currentStep === 'Details' ? (
|
{state.currentStep === 'Details' ? (
|
||||||
<StepDetails />
|
<StepDetails />
|
||||||
) : state.currentStep === 'Profiles' ? (
|
) : state.currentStep === 'Profiles' ? (
|
||||||
@@ -376,18 +347,9 @@ function WizardInner({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Container({
|
function Container({children}: {children: React.ReactNode}) {
|
||||||
showDeleteBtn,
|
|
||||||
deleteStarterPack,
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
showDeleteBtn: boolean
|
|
||||||
deleteStarterPack: () => Promise<void>
|
|
||||||
children: React.ReactNode
|
|
||||||
}) {
|
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const [state, dispatch] = useWizardState()
|
const [state, dispatch] = useWizardState()
|
||||||
const control = useDialogControl()
|
|
||||||
|
|
||||||
if (state.currentStep === 'Profiles' || state.currentStep === 'Feeds') {
|
if (state.currentStep === 'Profiles' || state.currentStep === 'Feeds') {
|
||||||
return <View style={[a.flex_1]}>{children}</View>
|
return <View style={[a.flex_1]}>{children}</View>
|
||||||
@@ -412,36 +374,6 @@ function Container({
|
|||||||
<Trans>Next</Trans>
|
<Trans>Next</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
{showDeleteBtn && (
|
|
||||||
<Button
|
|
||||||
label={_(msg`Next`)}
|
|
||||||
variant="ghost"
|
|
||||||
color="negative"
|
|
||||||
size="medium"
|
|
||||||
style={[a.mx_xl, a.mb_lg]}
|
|
||||||
onPress={control.open}
|
|
||||||
disabled={!state.canNext}>
|
|
||||||
<ButtonText>
|
|
||||||
<Trans>Delete</Trans>
|
|
||||||
</ButtonText>
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
<Prompt.Outer control={control}>
|
|
||||||
<Prompt.TitleText>
|
|
||||||
<Trans>Delete starter pack?</Trans>
|
|
||||||
</Prompt.TitleText>
|
|
||||||
<Prompt.DescriptionText>
|
|
||||||
<Trans>Are you sure you want delete this starter pack?</Trans>
|
|
||||||
</Prompt.DescriptionText>
|
|
||||||
<Prompt.Actions>
|
|
||||||
<Prompt.Action
|
|
||||||
onPress={deleteStarterPack}
|
|
||||||
color="negative"
|
|
||||||
cta={_(msg`Delete`)}
|
|
||||||
/>
|
|
||||||
<Prompt.Cancel />
|
|
||||||
</Prompt.Actions>
|
|
||||||
</Prompt.Outer>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</KeyboardAwareScrollView>
|
</KeyboardAwareScrollView>
|
||||||
|
|||||||
Reference in New Issue
Block a user