···11-import React from 'react'
22-import {View} from 'react-native'
33-import {LABELS} from '@atproto/api'
44-import {msg, Trans} from '@lingui/macro'
55-import {useLingui} from '@lingui/react'
66-77-import {useAnalytics} from '#/lib/analytics/analytics'
88-import {logEvent} from '#/lib/statsig/statsig'
99-import {usePreferencesQuery} from '#/state/queries/preferences'
1010-import {usePreferencesSetAdultContentMutation} from 'state/queries/preferences'
1111-import {
1212- DescriptionText,
1313- OnboardingControls,
1414- TitleText,
1515-} from '#/screens/Onboarding/Layout'
1616-import {Context} from '#/screens/Onboarding/state'
1717-import {AdultContentEnabledPref} from '#/screens/Onboarding/StepModeration/AdultContentEnabledPref'
1818-import {ModerationOption} from '#/screens/Onboarding/StepModeration/ModerationOption'
1919-import {atoms as a} from '#/alf'
2020-import {Button, ButtonIcon, ButtonText} from '#/components/Button'
2121-import {IconCircle} from '#/components/IconCircle'
2222-import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '#/components/icons/Chevron'
2323-import {EyeSlash_Stroke2_Corner0_Rounded as EyeSlash} from '#/components/icons/EyeSlash'
2424-import {Loader} from '#/components/Loader'
2525-2626-export function StepModeration() {
2727- const {_} = useLingui()
2828- const {track} = useAnalytics()
2929- const {state, dispatch} = React.useContext(Context)
3030- const {data: preferences} = usePreferencesQuery()
3131- const {mutate, variables} = usePreferencesSetAdultContentMutation()
3232-3333- // We need to know if the screen is mounted so we know if we want to run entering animations
3434- // https://github.com/software-mansion/react-native-reanimated/discussions/2513
3535- const isMounted = React.useRef(false)
3636- React.useLayoutEffect(() => {
3737- isMounted.current = true
3838- }, [])
3939-4040- const adultContentEnabled = !!(
4141- (variables && variables.enabled) ||
4242- (!variables && preferences?.moderationPrefs.adultContentEnabled)
4343- )
4444-4545- const onContinue = React.useCallback(() => {
4646- dispatch({type: 'next'})
4747- track('OnboardingV2:StepModeration:End')
4848- logEvent('onboarding:moderation:nextPressed', {})
4949- }, [track, dispatch])
5050-5151- React.useEffect(() => {
5252- track('OnboardingV2:StepModeration:Start')
5353- }, [track])
5454-5555- return (
5656- <View style={[a.align_start]}>
5757- <IconCircle icon={EyeSlash} style={[a.mb_2xl]} />
5858-5959- <TitleText>
6060- <Trans>You're in control</Trans>
6161- </TitleText>
6262- <DescriptionText style={[a.mb_xl]}>
6363- <Trans>
6464- Select what you want to see (or not see), and we’ll handle the rest.
6565- </Trans>
6666- </DescriptionText>
6767-6868- {!preferences ? (
6969- <View style={[a.pt_md]}>
7070- <Loader size="xl" />
7171- </View>
7272- ) : (
7373- <>
7474- <AdultContentEnabledPref mutate={mutate} variables={variables} />
7575-7676- <View style={[a.gap_sm, a.w_full]}>
7777- <ModerationOption
7878- labelValueDefinition={LABELS.porn}
7979- disabled={!adultContentEnabled}
8080- />
8181- <ModerationOption
8282- labelValueDefinition={LABELS.sexual}
8383- disabled={!adultContentEnabled}
8484- />
8585- <ModerationOption
8686- labelValueDefinition={LABELS['graphic-media']}
8787- disabled={!adultContentEnabled}
8888- />
8989- <ModerationOption labelValueDefinition={LABELS.nudity} />
9090- </View>
9191- </>
9292- )}
9393-9494- <OnboardingControls.Portal>
9595- <Button
9696- key={state.activeStep} // remove focus state on nav
9797- variant="gradient"
9898- color="gradient_sky"
9999- size="large"
100100- label={_(msg`Continue to next step`)}
101101- onPress={onContinue}>
102102- <ButtonText>
103103- <Trans>Continue</Trans>
104104- </ButtonText>
105105- <ButtonIcon icon={ChevronRight} position="right" />
106106- </Button>
107107- </OnboardingControls.Portal>
108108- </View>
109109- )
110110-}
+1-5
src/screens/Onboarding/StepProfile/index.tsx
···9292 }, [track])
93939494 React.useEffect(() => {
9595- // We have an experiment running for redueced onboarding, where this screen shows up as the first in onboarding.
9696- // We only want to request permissions when that gate is actually active to prevent pollution
9797- if (gate('reduced_onboarding_and_home_algo_v2')) {
9898- requestNotificationsPermission('StartOnboarding')
9999- }
9595+ requestNotificationsPermission('StartOnboarding')
10096 }, [gate, requestNotificationsPermission])
1019710298 const openPicker = React.useCallback(