clean up onSuccess callback

This commit is contained in:
Chenyu Huang
2025-08-19 15:59:12 -07:00
parent f42b5831bb
commit e32f280f47
3 changed files with 16 additions and 26 deletions
+5 -18
View File
@@ -35,16 +35,6 @@ import {TimesLarge_Stroke2_Corner0_Rounded} from '../icons/Times'
type StarterPackWithMembership =
AppBskyGraphGetStarterPacksWithMembership.StarterPackWithMembership
let dialogCallbacks: {
onSuccess?: () => void
} = {}
export function notifyDialogSuccess() {
if (dialogCallbacks.onSuccess) {
dialogCallbacks.onSuccess()
}
}
export type StarterPackDialogProps = {
control: Dialog.DialogControlProps
targetDid: string
@@ -60,19 +50,16 @@ export function StarterPackDialog({
const navigation = useNavigation<NavigationProp>()
const requireEmailVerification = useRequireEmailVerification()
React.useEffect(() => {
dialogCallbacks.onSuccess = () => {
if (!control.isOpen) {
control.open()
}
}
}, [control])
const navToWizard = React.useCallback(() => {
control.close()
navigation.navigate('StarterPackWizard', {
fromDialog: true,
targetDid: targetDid,
onSuccess: () => {
if (!control.isOpen) {
control.open()
}
},
})
}, [navigation, control, targetDid])
+5 -1
View File
@@ -79,7 +79,11 @@ export type CommonNavigatorParams = {
Start: {name: string; rkey: string}
StarterPack: {name: string; rkey: string; new?: boolean}
StarterPackShort: {code: string}
StarterPackWizard: {fromDialog?: boolean; targetDid?: string}
StarterPackWizard: {
fromDialog?: boolean
targetDid?: string
onSuccess?: () => void
}
StarterPackEdit: {rkey?: string}
VideoFeed: VideoFeedSourceContext
}
+6 -7
View File
@@ -54,7 +54,6 @@ import {StepProfiles} from '#/screens/StarterPack/Wizard/StepProfiles'
import {atoms as a, useTheme, web} from '#/alf'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import {useDialogControl} from '#/components/Dialog'
import {notifyDialogSuccess} from '#/components/dialogs/StarterPackDialog'
import * as Layout from '#/components/Layout'
import {ListMaybePlaceholder} from '#/components/Lists'
import {Loader} from '#/components/Loader'
@@ -73,6 +72,7 @@ export function Wizard({
const rkey = 'rkey' in params ? params.rkey : undefined
const fromDialog = 'fromDialog' in params ? params.fromDialog : false
const targetDid = 'targetDid' in params ? params.targetDid : undefined
const onSuccess = 'onSuccess' in params ? params.onSuccess : undefined
const {currentAccount} = useSession()
const moderationOpts = useModerationOpts()
@@ -144,6 +144,7 @@ export function Wizard({
profile={profile}
moderationOpts={moderationOpts}
fromDialog={fromDialog}
onSuccess={onSuccess}
/>
</Provider>
</Layout.Screen>
@@ -156,12 +157,14 @@ function WizardInner({
profile,
moderationOpts,
fromDialog,
onSuccess,
}: {
currentStarterPack?: AppBskyGraphDefs.StarterPackView
currentListItems?: AppBskyGraphDefs.ListItemView[]
profile: AppBskyActorDefs.ProfileViewDetailed
moderationOpts: ModerationOpts
fromDialog?: boolean
onSuccess?: () => void
}) {
const navigation = useNavigation<NavigationProp>()
const {_} = useLingui()
@@ -231,7 +234,7 @@ function WizardInner({
// If launched from ProfileMenu dialog, notify the dialog and go back
if (fromDialog) {
navigation.goBack()
notifyDialogSuccess()
onSuccess?.()
} else {
// Original behavior for other entry points
navigation.replace('StarterPack', {
@@ -366,11 +369,7 @@ function WizardInner({
</Container>
{state.currentStep !== 'Details' && (
<Footer
onNext={onNext}
nextBtnText={currUiStrings.nextBtn}
profile={profile}
/>
<Footer onNext={onNext} nextBtnText={currUiStrings.nextBtn} />
)}
<WizardEditListDialog
control={editDialogControl}