diff --git a/src/screens/Onboarding/StepFinished.tsx b/src/screens/Onboarding/StepFinished.tsx index ad2c131c13..28b56d5537 100644 --- a/src/screens/Onboarding/StepFinished.tsx +++ b/src/screens/Onboarding/StepFinished.tsx @@ -13,7 +13,7 @@ import {Trending2_Stroke2_Corner2_Rounded as Trending} from '#/components/icons/ import {Text} from '#/components/Typography' import {useOnboardingDispatch} from '#/state/shell' import {Loader} from '#/components/Loader' -// import {useSetSaveFeedsMutation} from '#/state/queries/preferences' +import {useSetSaveFeedsMutation} from '#/state/queries/preferences' import {getAgent} from '#/state/session' import {useAnalytics} from '#/lib/analytics/analytics' @@ -25,10 +25,10 @@ import { } from '#/screens/Onboarding/Layout' import {IconCircle} from '#/components/IconCircle' import {uploadBlob} from 'lib/api' -// import { -// bulkWriteFollows, -// sortPrimaryAlgorithmFeeds, -// } from '#/screens/Onboarding/util' +import { + bulkWriteFollows, + sortPrimaryAlgorithmFeeds, +} from '#/screens/Onboarding/util' export function StepFinished() { const {_} = useLingui() @@ -38,38 +38,37 @@ export function StepFinished() { const {state, dispatch} = React.useContext(Context) const onboardDispatch = useOnboardingDispatch() const [saving, setSaving] = React.useState(false) - // const {mutateAsync: saveFeeds} = useSetSaveFeedsMutation() + const {mutateAsync: saveFeeds} = useSetSaveFeedsMutation() const finishOnboarding = React.useCallback(async () => { setSaving(true) // TODO uncomment const { - // interestsStepResults, - // suggestedAccountsStepResults, - // algoFeedsStepResults, - // topicalFeedsStepResults, + interestsStepResults, + suggestedAccountsStepResults, + algoFeedsStepResults, + topicalFeedsStepResults, profileStepResults, } = state - // const {selectedInterests} = interestsStepResults - // const selectedFeeds = [ - // ...sortPrimaryAlgorithmFeeds(algoFeedsStepResults.feedUris), - // ...topicalFeedsStepResults.feedUris, - // ] + const {selectedInterests} = interestsStepResults + const selectedFeeds = [ + ...sortPrimaryAlgorithmFeeds(algoFeedsStepResults.feedUris), + ...topicalFeedsStepResults.feedUris, + ] try { - // TODO uncomment! - // await Promise.all([ - // bulkWriteFollows(suggestedAccountsStepResults.accountDids), - // // these must be serial - // (async () => { - // await getAgent().setInterestsPref({tags: selectedInterests}) - // await saveFeeds({ - // saved: selectedFeeds, - // pinned: selectedFeeds, - // }) - // })(), - // ]) + await Promise.all([ + bulkWriteFollows(suggestedAccountsStepResults.accountDids), + // these must be serial + (async () => { + await getAgent().setInterestsPref({tags: selectedInterests}) + await saveFeeds({ + saved: selectedFeeds, + pinned: selectedFeeds, + }) + })(), + ]) await getAgent().upsertProfile(async existing => { existing = existing ?? {} @@ -99,7 +98,7 @@ export function StepFinished() { onboardDispatch({type: 'finish'}) track('OnboardingV2:StepFinished:End') track('OnboardingV2:Complete') - }, [dispatch, onboardDispatch, state, track]) + }, [dispatch, onboardDispatch, saveFeeds, state, track]) React.useEffect(() => { track('OnboardingV2:StepFinished:Start') diff --git a/src/screens/Onboarding/StepProfile/SelectImageButton.tsx b/src/screens/Onboarding/StepProfile/SelectImageButton.tsx index cb4d3d7ef3..d70f095a45 100644 --- a/src/screens/Onboarding/StepProfile/SelectImageButton.tsx +++ b/src/screens/Onboarding/StepProfile/SelectImageButton.tsx @@ -6,6 +6,8 @@ import {useTheme} from '#/alf' import {usePhotoLibraryPermission} from 'lib/hooks/usePermissions' import {openPicker} from 'lib/media/picker.shared' import {openCropper} from 'lib/media/picker' +import {compressIfNeeded} from 'lib/media/manip' +import {isWeb} from 'platform/detection' export function SelectImageButton() { const t = useTheme() @@ -23,6 +25,17 @@ export function SelectImageButton() { const item = items[0] if (!item) return + // TODO we need an alf modal for the cropper + if (isWeb) { + const compressedImage = await compressIfNeeded(item) + + setAvatar(prev => ({ + ...prev, + image: compressedImage, + })) + return + } + const croppedImage = await openCropper({ mediaType: 'photo', cropperCircleOverlay: true, @@ -31,9 +44,11 @@ export function SelectImageButton() { path: item.path, }) + const compressedImage = await compressIfNeeded(croppedImage) + setAvatar(prev => ({ ...prev, - image: croppedImage, + image: compressedImage, })) }, [requestPhotoAccessIfNeeded, setAvatar]) diff --git a/src/screens/Onboarding/StepProfile/index.tsx b/src/screens/Onboarding/StepProfile/index.tsx index e39d174a5e..97b5c62a11 100644 --- a/src/screens/Onboarding/StepProfile/index.tsx +++ b/src/screens/Onboarding/StepProfile/index.tsx @@ -62,20 +62,9 @@ export function StepProfile() { placeholder: emojiItems.smile, backgroundColor: '#338388', }) - const [uri, setUri] = React.useState('') const canvasRef = React.useRef(null) - // React.useEffect(() => { - // // TODO remove, this is for testing - // ;(async () => { - // const res = await canvasRef.current?.capture() - // if (res) { - // setUri(res) - // } - // })() - // }, [avatar]) - React.useEffect(() => { track('OnboardingV2:StepProfile:Start') }, [track]) @@ -123,12 +112,6 @@ export function StepProfile() { - {/* TODO remove, testing */} -