about summary refs log tree commit diff
path: root/src/screens/Onboarding/state.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/screens/Onboarding/state.ts')
-rw-r--r--src/screens/Onboarding/state.ts218
1 files changed, 14 insertions, 204 deletions
diff --git a/src/screens/Onboarding/state.ts b/src/screens/Onboarding/state.ts
index 50d815674..8f61cb22e 100644
--- a/src/screens/Onboarding/state.ts
+++ b/src/screens/Onboarding/state.ts
@@ -6,31 +6,13 @@ import {AvatarColor, Emoji} from '#/screens/Onboarding/StepProfile/types'
 export type OnboardingState = {
   hasPrev: boolean
   totalSteps: number
-  activeStep:
-    | 'profile'
-    | 'interests'
-    | 'suggestedAccounts'
-    | 'followingFeed'
-    | 'algoFeeds'
-    | 'topicalFeeds'
-    | 'moderation'
-    | 'profile'
-    | 'finished'
+  activeStep: 'profile' | 'interests' | 'finished'
   activeStepIndex: number
 
   interestsStepResults: {
     selectedInterests: string[]
     apiResponse: ApiResponseMap
   }
-  suggestedAccountsStepResults: {
-    accountDids: string[]
-  }
-  algoFeedsStepResults: {
-    feedUris: string[]
-  }
-  topicalFeedsStepResults: {
-    feedUris: string[]
-  }
   profileStepResults: {
     isCreatedAvatar: boolean
     image?: {
@@ -65,18 +47,6 @@ export type OnboardingAction =
       apiResponse: ApiResponseMap
     }
   | {
-      type: 'setSuggestedAccountsStepResults'
-      accountDids: string[]
-    }
-  | {
-      type: 'setAlgoFeedsStepResults'
-      feedUris: string[]
-    }
-  | {
-      type: 'setTopicalFeedsStepResults'
-      feedUris: string[]
-    }
-  | {
       type: 'setProfileStepResults'
       isCreatedAvatar: boolean
       image?: OnboardingState['profileStepResults']['image']
@@ -98,37 +68,6 @@ export type ApiResponseMap = {
   }
 }
 
-export const initialState: OnboardingState = {
-  hasPrev: false,
-  totalSteps: 7,
-  activeStep: 'interests',
-  activeStepIndex: 1,
-
-  interestsStepResults: {
-    selectedInterests: [],
-    apiResponse: {
-      interests: [],
-      suggestedAccountDids: {},
-      suggestedFeedUris: {},
-    },
-  },
-  suggestedAccountsStepResults: {
-    accountDids: [],
-  },
-  algoFeedsStepResults: {
-    feedUris: [],
-  },
-  topicalFeedsStepResults: {
-    feedUris: [],
-  },
-  profileStepResults: {
-    isCreatedAvatar: false,
-    image: undefined,
-    imageUri: '',
-    imageMime: '',
-  },
-}
-
 export const INTEREST_TO_DISPLAY_NAME_DEFAULTS: {
   [key: string]: string
 } = {
@@ -156,125 +95,7 @@ export const INTEREST_TO_DISPLAY_NAME_DEFAULTS: {
   cooking: 'Cooking',
 }
 
-export const Context = React.createContext<{
-  state: OnboardingState
-  dispatch: React.Dispatch<OnboardingAction>
-  interestsDisplayNames: {[key: string]: string}
-}>({
-  state: {...initialState},
-  dispatch: () => {},
-  interestsDisplayNames: INTEREST_TO_DISPLAY_NAME_DEFAULTS,
-})
-
-export function reducer(
-  s: OnboardingState,
-  a: OnboardingAction,
-): OnboardingState {
-  let next = {...s}
-
-  switch (a.type) {
-    case 'next': {
-      if (s.activeStep === 'interests') {
-        next.activeStep = 'suggestedAccounts'
-        next.activeStepIndex = 2
-      } else if (s.activeStep === 'suggestedAccounts') {
-        next.activeStep = 'followingFeed'
-        next.activeStepIndex = 3
-      } else if (s.activeStep === 'followingFeed') {
-        next.activeStep = 'algoFeeds'
-        next.activeStepIndex = 4
-      } else if (s.activeStep === 'algoFeeds') {
-        next.activeStep = 'topicalFeeds'
-        next.activeStepIndex = 5
-      } else if (s.activeStep === 'topicalFeeds') {
-        next.activeStep = 'moderation'
-        next.activeStepIndex = 6
-      } else if (s.activeStep === 'moderation') {
-        next.activeStep = 'finished'
-        next.activeStepIndex = 7
-      }
-      break
-    }
-    case 'prev': {
-      if (s.activeStep === 'suggestedAccounts') {
-        next.activeStep = 'interests'
-        next.activeStepIndex = 1
-      } else if (s.activeStep === 'followingFeed') {
-        next.activeStep = 'suggestedAccounts'
-        next.activeStepIndex = 2
-      } else if (s.activeStep === 'algoFeeds') {
-        next.activeStep = 'followingFeed'
-        next.activeStepIndex = 3
-      } else if (s.activeStep === 'topicalFeeds') {
-        next.activeStep = 'algoFeeds'
-        next.activeStepIndex = 4
-      } else if (s.activeStep === 'moderation') {
-        next.activeStep = 'topicalFeeds'
-        next.activeStepIndex = 5
-      } else if (s.activeStep === 'finished') {
-        next.activeStep = 'moderation'
-        next.activeStepIndex = 6
-      }
-      break
-    }
-    case 'finish': {
-      next = initialState
-      break
-    }
-    case 'setInterestsStepResults': {
-      next.interestsStepResults = {
-        selectedInterests: a.selectedInterests,
-        apiResponse: a.apiResponse,
-      }
-      break
-    }
-    case 'setSuggestedAccountsStepResults': {
-      next.suggestedAccountsStepResults = {
-        accountDids: next.suggestedAccountsStepResults.accountDids.concat(
-          a.accountDids,
-        ),
-      }
-      break
-    }
-    case 'setAlgoFeedsStepResults': {
-      next.algoFeedsStepResults = {
-        feedUris: a.feedUris,
-      }
-      break
-    }
-    case 'setTopicalFeedsStepResults': {
-      next.topicalFeedsStepResults = {
-        feedUris: next.topicalFeedsStepResults.feedUris.concat(a.feedUris),
-      }
-      break
-    }
-  }
-
-  const state = {
-    ...next,
-    hasPrev: next.activeStep !== 'interests',
-  }
-
-  logger.debug(`onboarding`, {
-    hasPrev: state.hasPrev,
-    activeStep: state.activeStep,
-    activeStepIndex: state.activeStepIndex,
-    interestsStepResults: {
-      selectedInterests: state.interestsStepResults.selectedInterests,
-    },
-    suggestedAccountsStepResults: state.suggestedAccountsStepResults,
-    algoFeedsStepResults: state.algoFeedsStepResults,
-    topicalFeedsStepResults: state.topicalFeedsStepResults,
-  })
-
-  if (s.activeStep !== state.activeStep) {
-    logger.debug(`onboarding: step changed`, {activeStep: state.activeStep})
-  }
-
-  return state
-}
-
-export const initialStateReduced: OnboardingState = {
+export const initialState: OnboardingState = {
   hasPrev: false,
   totalSteps: 3,
   activeStep: 'profile',
@@ -288,15 +109,6 @@ export const initialStateReduced: OnboardingState = {
       suggestedFeedUris: {},
     },
   },
-  suggestedAccountsStepResults: {
-    accountDids: [],
-  },
-  algoFeedsStepResults: {
-    feedUris: [],
-  },
-  topicalFeedsStepResults: {
-    feedUris: [],
-  },
   profileStepResults: {
     isCreatedAvatar: false,
     image: undefined,
@@ -305,7 +117,17 @@ export const initialStateReduced: OnboardingState = {
   },
 }
 
-export function reducerReduced(
+export const Context = React.createContext<{
+  state: OnboardingState
+  dispatch: React.Dispatch<OnboardingAction>
+  interestsDisplayNames: {[key: string]: string}
+}>({
+  state: {...initialState},
+  dispatch: () => {},
+  interestsDisplayNames: INTEREST_TO_DISPLAY_NAME_DEFAULTS,
+})
+
+export function reducer(
   s: OnboardingState,
   a: OnboardingAction,
 ): OnboardingState {
@@ -333,7 +155,7 @@ export function reducerReduced(
       break
     }
     case 'finish': {
-      next = initialStateReduced
+      next = initialState
       break
     }
     case 'setInterestsStepResults': {
@@ -343,15 +165,6 @@ export function reducerReduced(
       }
       break
     }
-    case 'setSuggestedAccountsStepResults': {
-      break
-    }
-    case 'setAlgoFeedsStepResults': {
-      break
-    }
-    case 'setTopicalFeedsStepResults': {
-      break
-    }
     case 'setProfileStepResults': {
       next.profileStepResults = {
         isCreatedAvatar: a.isCreatedAvatar,
@@ -376,9 +189,6 @@ export function reducerReduced(
     interestsStepResults: {
       selectedInterests: state.interestsStepResults.selectedInterests,
     },
-    suggestedAccountsStepResults: state.suggestedAccountsStepResults,
-    algoFeedsStepResults: state.algoFeedsStepResults,
-    topicalFeedsStepResults: state.topicalFeedsStepResults,
     profileStepResults: state.profileStepResults,
   })