Fork more code

This commit is contained in:
Dan Abramov
2024-10-22 21:15:42 +01:00
parent 371cabfabc
commit 8cc8df6171
+16 -54
View File
@@ -233,12 +233,12 @@ function CreateAnother() {
t.atoms.border_contrast_low, t.atoms.border_contrast_low,
]}> ]}>
<Button <Button
label={_(msg`Create a starter pack`)} label={_(msg`Create a feed`)}
variant="solid" variant="solid"
color="secondary" color="secondary"
size="small" size="small"
style={[a.self_center]} style={[a.self_center]}
onPress={() => navigation.navigate('StarterPackWizard')}> onPress={() => navigation.navigate('FeedWizard')}>
<ButtonText> <ButtonText>
<Trans>Create another</Trans> <Trans>Create another</Trans>
</ButtonText> </ButtonText>
@@ -252,37 +252,33 @@ function Empty() {
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()
const navigation = useNavigation<NavigationProp>() const navigation = useNavigation<NavigationProp>()
const confirmDialogControl = useDialogControl()
const followersDialogControl = useDialogControl()
const errorDialogControl = useDialogControl() const errorDialogControl = useDialogControl()
const [isGenerating, setIsGenerating] = React.useState(false) const [isCreating, setIsCreating] = React.useState(false)
const {mutate: generateStarterPack} = useGenerateStarterPackMutation({ // TODO
const {mutate: createFeed} = useGenerateStarterPackMutation({
onSuccess: ({uri}) => { onSuccess: ({uri}) => {
// TODO
const parsed = parseStarterPackUri(uri) const parsed = parseStarterPackUri(uri)
if (parsed) { if (parsed) {
navigation.push('StarterPack', { navigation.push('ProfileFeed', {
name: parsed.name, name: parsed.name,
rkey: parsed.rkey, rkey: parsed.rkey,
}) })
} }
setIsGenerating(false) setIsCreating(false)
}, },
onError: e => { onError: e => {
logger.error('Failed to generate starter pack', {safeMessage: e}) logger.error('Failed to generate feed', {safeMessage: e})
setIsGenerating(false) setIsCreating(false)
if (e.name === 'NOT_ENOUGH_FOLLOWERS') { errorDialogControl.open()
followersDialogControl.open()
} else {
errorDialogControl.open()
}
}, },
}) })
const generate = () => { const generate = () => {
setIsGenerating(true) setIsCreating(true)
generateStarterPack() createFeed()
} }
return ( return (
@@ -317,8 +313,8 @@ function Empty() {
variant="ghost" variant="ghost"
color="primary" color="primary"
size="small" size="small"
disabled={isGenerating} disabled={isCreating}
onPress={() => navigation.navigate('StarterPackWizard')} onPress={() => navigation.navigate('FeedWizard')}
style={{ style={{
backgroundColor: 'white', backgroundColor: 'white',
borderColor: 'white', borderColor: 'white',
@@ -331,45 +327,11 @@ function Empty() {
</Button> </Button>
</View> </View>
<Prompt.Outer control={confirmDialogControl}>
<Prompt.TitleText>
<Trans>Generate a starter pack</Trans>
</Prompt.TitleText>
<Prompt.DescriptionText>
<Trans>
Bluesky will choose a set of recommended accounts from people in
your network.
</Trans>
</Prompt.DescriptionText>
<Prompt.Actions>
<Prompt.Action
color="primary"
cta={_(msg`Choose for me`)}
onPress={generate}
/>
<Prompt.Action
color="secondary"
cta={_(msg`Let me choose`)}
onPress={() => {
navigation.navigate('StarterPackWizard')
}}
/>
</Prompt.Actions>
</Prompt.Outer>
<Prompt.Basic
control={followersDialogControl}
title={_(msg`Oops!`)}
description={_(
msg`You must be following at least seven other people to generate a starter pack.`,
)}
onConfirm={() => {}}
showCancel={false}
/>
<Prompt.Basic <Prompt.Basic
control={errorDialogControl} control={errorDialogControl}
title={_(msg`Oops!`)} title={_(msg`Oops!`)}
description={_( description={_(
msg`An error occurred while generating your starter pack. Want to try again?`, msg`An error occurred while creating your feed. Want to try again?`,
)} )}
onConfirm={generate} onConfirm={generate}
confirmButtonCta={_(msg`Retry`)} confirmButtonCta={_(msg`Retry`)}