[Reduced Onboarding] Fix forward/backward nav with profile step (#3997)
* WIP * Fix forward-backward to profile step * [Reduced Onboarding] Add avatar metric (#3999) * Add prop to finished event * Fix type * Use separate event
This commit is contained in:
		
							parent
							
								
									9980012021
								
							
						
					
					
						commit
						95514e3af7
					
				
					 4 changed files with 37 additions and 4 deletions
				
			
		|  | @ -53,6 +53,9 @@ export type LogEvents = { | ||||||
|   'onboarding:moderation:nextPressed': {} |   'onboarding:moderation:nextPressed': {} | ||||||
|   'onboarding:profile:nextPressed': {} |   'onboarding:profile:nextPressed': {} | ||||||
|   'onboarding:finished:nextPressed': {} |   'onboarding:finished:nextPressed': {} | ||||||
|  |   'onboarding:finished:avatarResult': { | ||||||
|  |     avatarResult: 'default' | 'created' | 'uploaded' | ||||||
|  |   } | ||||||
|   'home:feedDisplayed': { |   'home:feedDisplayed': { | ||||||
|     feedUrl: string |     feedUrl: string | ||||||
|     feedType: string |     feedType: string | ||||||
|  |  | ||||||
|  | @ -134,6 +134,14 @@ export function StepFinished() { | ||||||
|               return existing |               return existing | ||||||
|             }) |             }) | ||||||
|           } |           } | ||||||
|  | 
 | ||||||
|  |           logEvent('onboarding:finished:avatarResult', { | ||||||
|  |             avatarResult: profileStepResults.isCreatedAvatar | ||||||
|  |               ? 'created' | ||||||
|  |               : profileStepResults.image | ||||||
|  |               ? 'uploaded' | ||||||
|  |               : 'default', | ||||||
|  |           }) | ||||||
|         })(), |         })(), | ||||||
|       ]) |       ]) | ||||||
|     } catch (e: any) { |     } catch (e: any) { | ||||||
|  |  | ||||||
|  | @ -79,9 +79,10 @@ export function StepProfile() { | ||||||
|   const {state, dispatch} = React.useContext(Context) |   const {state, dispatch} = React.useContext(Context) | ||||||
|   const [avatar, setAvatar] = React.useState<Avatar>({ |   const [avatar, setAvatar] = React.useState<Avatar>({ | ||||||
|     image: state.profileStepResults?.image, |     image: state.profileStepResults?.image, | ||||||
|     placeholder: emojiItems.at, |     placeholder: state.profileStepResults.creatorState?.emoji || emojiItems.at, | ||||||
|     backgroundColor: randomColor, |     backgroundColor: | ||||||
|     useCreatedAvatar: false, |       state.profileStepResults.creatorState?.backgroundColor || randomColor, | ||||||
|  |     useCreatedAvatar: state.profileStepResults.isCreatedAvatar, | ||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|   const canvasRef = React.useRef<PlaceholderCanvasRef>(null) |   const canvasRef = React.useRef<PlaceholderCanvasRef>(null) | ||||||
|  | @ -144,17 +145,23 @@ export function StepProfile() { | ||||||
|         image: avatar.image, |         image: avatar.image, | ||||||
|         imageUri, |         imageUri, | ||||||
|         imageMime: avatar.image?.mime ?? 'image/jpeg', |         imageMime: avatar.image?.mime ?? 'image/jpeg', | ||||||
|  |         isCreatedAvatar: avatar.useCreatedAvatar, | ||||||
|  |         creatorState: { | ||||||
|  |           emoji: avatar.placeholder, | ||||||
|  |           backgroundColor: avatar.backgroundColor, | ||||||
|  |         }, | ||||||
|       }) |       }) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     dispatch({type: 'next'}) |     dispatch({type: 'next'}) | ||||||
|     track('OnboardingV2:StepProfile:End') |     track('OnboardingV2:StepProfile:End') | ||||||
|     logEvent('onboarding:profile:nextPressed', {}) |     logEvent('onboarding:profile:nextPressed', {}) | ||||||
|   }, [avatar.image, avatar.useCreatedAvatar, dispatch, track]) |   }, [avatar, dispatch, track]) | ||||||
| 
 | 
 | ||||||
|   const onDoneCreating = React.useCallback(() => { |   const onDoneCreating = React.useCallback(() => { | ||||||
|     setAvatar(prev => ({ |     setAvatar(prev => ({ | ||||||
|       ...prev, |       ...prev, | ||||||
|  |       image: undefined, | ||||||
|       useCreatedAvatar: true, |       useCreatedAvatar: true, | ||||||
|     })) |     })) | ||||||
|     creatorControl.close() |     creatorControl.close() | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| import React from 'react' | import React from 'react' | ||||||
| 
 | 
 | ||||||
| import {logger} from '#/logger' | import {logger} from '#/logger' | ||||||
|  | import {AvatarColor, Emoji} from '#/screens/Onboarding/StepProfile/types' | ||||||
| 
 | 
 | ||||||
| export type OnboardingState = { | export type OnboardingState = { | ||||||
|   hasPrev: boolean |   hasPrev: boolean | ||||||
|  | @ -31,6 +32,7 @@ export type OnboardingState = { | ||||||
|     feedUris: string[] |     feedUris: string[] | ||||||
|   } |   } | ||||||
|   profileStepResults: { |   profileStepResults: { | ||||||
|  |     isCreatedAvatar: boolean | ||||||
|     image?: { |     image?: { | ||||||
|       path: string |       path: string | ||||||
|       mime: string |       mime: string | ||||||
|  | @ -40,6 +42,10 @@ export type OnboardingState = { | ||||||
|     } |     } | ||||||
|     imageUri?: string |     imageUri?: string | ||||||
|     imageMime?: string |     imageMime?: string | ||||||
|  |     creatorState?: { | ||||||
|  |       emoji: Emoji | ||||||
|  |       backgroundColor: AvatarColor | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -72,9 +78,14 @@ export type OnboardingAction = | ||||||
|     } |     } | ||||||
|   | { |   | { | ||||||
|       type: 'setProfileStepResults' |       type: 'setProfileStepResults' | ||||||
|  |       isCreatedAvatar: boolean | ||||||
|       image?: OnboardingState['profileStepResults']['image'] |       image?: OnboardingState['profileStepResults']['image'] | ||||||
|       imageUri: string |       imageUri: string | ||||||
|       imageMime: string |       imageMime: string | ||||||
|  |       creatorState?: { | ||||||
|  |         emoji: Emoji | ||||||
|  |         backgroundColor: AvatarColor | ||||||
|  |       } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| export type ApiResponseMap = { | export type ApiResponseMap = { | ||||||
|  | @ -111,6 +122,7 @@ export const initialState: OnboardingState = { | ||||||
|     feedUris: [], |     feedUris: [], | ||||||
|   }, |   }, | ||||||
|   profileStepResults: { |   profileStepResults: { | ||||||
|  |     isCreatedAvatar: false, | ||||||
|     image: undefined, |     image: undefined, | ||||||
|     imageUri: '', |     imageUri: '', | ||||||
|     imageMime: '', |     imageMime: '', | ||||||
|  | @ -286,6 +298,7 @@ export const initialStateReduced: OnboardingState = { | ||||||
|     feedUris: [], |     feedUris: [], | ||||||
|   }, |   }, | ||||||
|   profileStepResults: { |   profileStepResults: { | ||||||
|  |     isCreatedAvatar: false, | ||||||
|     image: undefined, |     image: undefined, | ||||||
|     imageUri: '', |     imageUri: '', | ||||||
|     imageMime: '', |     imageMime: '', | ||||||
|  | @ -341,9 +354,11 @@ export function reducerReduced( | ||||||
|     } |     } | ||||||
|     case 'setProfileStepResults': { |     case 'setProfileStepResults': { | ||||||
|       next.profileStepResults = { |       next.profileStepResults = { | ||||||
|  |         isCreatedAvatar: a.isCreatedAvatar, | ||||||
|         image: a.image, |         image: a.image, | ||||||
|         imageUri: a.imageUri, |         imageUri: a.imageUri, | ||||||
|         imageMime: a.imageMime, |         imageMime: a.imageMime, | ||||||
|  |         creatorState: a.creatorState, | ||||||
|       } |       } | ||||||
|       break |       break | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue