about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/components/dialogs/StarterPackDialog.tsx23
-rw-r--r--src/lib/routes/types.ts6
-rw-r--r--src/screens/StarterPack/Wizard/index.tsx13
3 files changed, 16 insertions, 26 deletions
diff --git a/src/components/dialogs/StarterPackDialog.tsx b/src/components/dialogs/StarterPackDialog.tsx
index 0570859c4..9c36be84d 100644
--- a/src/components/dialogs/StarterPackDialog.tsx
+++ b/src/components/dialogs/StarterPackDialog.tsx
@@ -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])
 
diff --git a/src/lib/routes/types.ts b/src/lib/routes/types.ts
index f7e7c7eed..1725fdfb4 100644
--- a/src/lib/routes/types.ts
+++ b/src/lib/routes/types.ts
@@ -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
 }
diff --git a/src/screens/StarterPack/Wizard/index.tsx b/src/screens/StarterPack/Wizard/index.tsx
index b2f74257b..a871a68a4 100644
--- a/src/screens/StarterPack/Wizard/index.tsx
+++ b/src/screens/StarterPack/Wizard/index.tsx
@@ -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}