Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[AAv2] Fix for mod screen (#9483)

* Add derived flags, add back disabled adult content for users under 18

* Update copy

authored by

Eric Bailey and committed by
GitHub
e3494a48 59aa2bd8

+68 -26
+25 -5
src/ageAssurance/index.tsx
··· 3 3 import {useGetAndRegisterPushToken} from '#/lib/notifications/notifications' 4 4 import {Provider as RedirectOverlayProvider} from '#/ageAssurance/components/RedirectOverlay' 5 5 import {AgeAssuranceDataProvider} from '#/ageAssurance/data' 6 + import {useAgeAssuranceDataContext} from '#/ageAssurance/data' 6 7 import {logger} from '#/ageAssurance/logger' 7 8 import { 8 9 useAgeAssuranceState, ··· 13 14 type AgeAssuranceState, 14 15 AgeAssuranceStatus, 15 16 } from '#/ageAssurance/types' 17 + import {isUserUnderAdultAge} from '#/ageAssurance/util' 16 18 17 19 export { 18 20 prefetchConfig as prefetchAgeAssuranceConfig, ··· 27 29 Access: typeof AgeAssuranceAccess 28 30 Status: typeof AgeAssuranceStatus 29 31 state: AgeAssuranceState 32 + flags: { 33 + adultContentDisabled: boolean 34 + chatDisabled: boolean 35 + } 30 36 }>({ 31 37 Access: AgeAssuranceAccess, 32 38 Status: AgeAssuranceStatus, ··· 35 41 status: AgeAssuranceStatus.Unknown, 36 42 access: AgeAssuranceAccess.Full, 37 43 }, 44 + flags: { 45 + adultContentDisabled: false, 46 + chatDisabled: false, 47 + }, 38 48 }) 39 49 40 50 /** ··· 58 68 59 69 function InnerProvider({children}: {children: React.ReactNode}) { 60 70 const state = useAgeAssuranceState() 71 + const {data} = useAgeAssuranceDataContext() 61 72 const getAndRegisterPushToken = useGetAndRegisterPushToken() 62 73 63 74 const handleAccessUpdate = useCallback( ··· 76 87 77 88 return ( 78 89 <AgeAssuranceStateContext.Provider 79 - value={useMemo( 80 - () => ({ 90 + value={useMemo(() => { 91 + const chatDisabled = state.access !== AgeAssuranceAccess.Full 92 + const isUnderage = data?.birthdate 93 + ? isUserUnderAdultAge(data.birthdate) 94 + : true 95 + const adultContentDisabled = 96 + state.access !== AgeAssuranceAccess.Full || isUnderage 97 + return { 81 98 Access: AgeAssuranceAccess, 82 99 Status: AgeAssuranceStatus, 83 100 state, 84 - }), 85 - [state], 86 - )}> 101 + flags: { 102 + adultContentDisabled, 103 + chatDisabled, 104 + }, 105 + } 106 + }, [state, data])}> 87 107 {children} 88 108 </AgeAssuranceStateContext.Provider> 89 109 )
+4
src/ageAssurance/util.ts
··· 82 82 export function isUserUnderMinimumAge(birthDate: string) { 83 83 return getAge(new Date(birthDate)) < DEFAULT_MIN_AGE 84 84 } 85 + 86 + export function isUserUnderAdultAge(birthDate: string) { 87 + return getAge(new Date(birthDate)) < 18 88 + }
+4 -12
src/components/ageAssurance/useAgeAssuranceCopy.ts
··· 2 2 import {msg} from '@lingui/macro' 3 3 import {useLingui} from '@lingui/react' 4 4 5 - import {useAgeAssurance} from '#/ageAssurance' 6 - 7 5 export function useAgeAssuranceCopy() { 8 6 const {_} = useLingui() 9 - const aa = useAgeAssurance() 10 7 11 8 return useMemo(() => { 12 9 return { 13 - notice: 14 - aa.state.access === aa.Access.Safe 15 - ? _( 16 - msg`Due to laws in your region, certain features on Bluesky are currently restricted until you're able to verify you're an adult.`, 17 - ) 18 - : _( 19 - msg`The laws in your location require you to verify you're an adult before accessing certain features on Bluesky, like adult content and direct messaging.`, 20 - ), 10 + notice: _( 11 + msg`Due to laws in your region, certain features on Bluesky are currently restricted until you're able to verify you're an adult.`, 12 + ), 21 13 banner: _( 22 14 msg`The laws in your location require you to verify you're an adult to access certain features. Tap to learn more.`, 23 15 ), ··· 25 17 msg`Don't worry! All existing messages and settings are saved and will be available after you verify you're an adult.`, 26 18 ), 27 19 } 28 - }, [_, aa]) 20 + }, [_]) 29 21 }
+35 -9
src/screens/Moderation/index.tsx
··· 12 12 } from '#/lib/routes/types' 13 13 import {logger} from '#/logger' 14 14 import {isIOS} from '#/platform/detection' 15 + import {useIsBirthdateUpdateAllowed} from '#/state/birthdate' 15 16 import { 16 17 useMyLabelersQuery, 17 18 usePreferencesQuery, ··· 21 22 import {isNonConfigurableModerationAuthority} from '#/state/session/additional-moderation-authorities' 22 23 import {useSetMinimalShellMode} from '#/state/shell' 23 24 import {atoms as a, useBreakpoints, useTheme, type ViewStyleProp} from '#/alf' 25 + import {Admonition} from '#/components/Admonition' 24 26 import {AgeAssuranceAdmonition} from '#/components/ageAssurance/AgeAssuranceAdmonition' 27 + import {useAgeAssuranceCopy} from '#/components/ageAssurance/useAgeAssuranceCopy' 25 28 import {Button} from '#/components/Button' 26 29 import {useGlobalDialogsControlContext} from '#/components/dialogs/Context' 27 30 import {Divider} from '#/components/Divider' ··· 164 167 error: labelersError, 165 168 } = useMyLabelersQuery() 166 169 const aa = useAgeAssurance() 170 + const isBirthdateUpdateAllowed = useIsBirthdateUpdateAllowed() 171 + const aaCopy = useAgeAssuranceCopy() 167 172 168 173 useFocusEffect( 169 174 useCallback(() => { ··· 173 178 174 179 const {mutateAsync: setAdultContentPref, variables: optimisticAdultContent} = 175 180 usePreferencesSetAdultContentMutation() 176 - const adultContentEnabled = !!( 181 + let adultContentEnabled = !!( 177 182 (optimisticAdultContent && optimisticAdultContent.enabled) || 178 183 (!optimisticAdultContent && preferences.moderationPrefs.adultContentEnabled) 179 184 ) 185 + const adultContentUIDisabledOnIOS = isIOS && !adultContentEnabled 186 + let adultContentUIDisabled = adultContentUIDisabledOnIOS 187 + 188 + if (aa.flags.adultContentDisabled) { 189 + adultContentEnabled = false 190 + adultContentUIDisabled = true 191 + } 180 192 181 193 const onToggleAdultContentEnabled = useCallback( 182 194 async (selected: boolean) => { ··· 193 205 [setAdultContentPref], 194 206 ) 195 207 196 - const disabledOnIOS = isIOS && !adultContentEnabled 197 - 198 208 return ( 199 209 <View style={[a.pt_2xl, a.px_lg, gtMobile && a.px_2xl]}> 210 + {aa.flags.adultContentDisabled && isBirthdateUpdateAllowed && ( 211 + <View style={[a.pb_2xl]}> 212 + <Admonition type="tip" style={[a.pb_md]}> 213 + <Trans> 214 + Your declared age is under 18. Some settings below may be 215 + disabled. If this was a mistake, you may edit your birthdate in 216 + your{' '} 217 + <InlineLinkText 218 + to="/settings/account" 219 + label={_(msg`Go to account settings`)}> 220 + account settings 221 + </InlineLinkText> 222 + . 223 + </Trans> 224 + </Admonition> 225 + </View> 226 + )} 227 + 200 228 <Text 201 229 style={[ 202 230 a.text_md, ··· 317 345 </Text> 318 346 319 347 <AgeAssuranceAdmonition style={[a.pb_md]}> 320 - <Trans> 321 - You must complete age assurance in order to access content filters. 322 - </Trans> 348 + {aaCopy.notice} 323 349 </AgeAssuranceAdmonition> 324 350 325 351 <View style={[a.gap_md]}> ··· 339 365 a.flex_row, 340 366 a.align_center, 341 367 a.justify_between, 342 - disabledOnIOS && {opacity: 0.5}, 368 + adultContentUIDisabled && {opacity: 0.5}, 343 369 ]}> 344 370 <Text style={[a.font_semi_bold, t.atoms.text_contrast_high]}> 345 371 <Trans>Enable adult content</Trans> 346 372 </Text> 347 373 <Toggle.Item 348 374 label={_(msg`Toggle to enable or disable adult content`)} 349 - disabled={disabledOnIOS} 375 + disabled={adultContentUIDisabled} 350 376 name="adultContent" 351 377 value={adultContentEnabled} 352 378 onChange={onToggleAdultContentEnabled}> ··· 362 388 </View> 363 389 </Toggle.Item> 364 390 </View> 365 - {disabledOnIOS && ( 391 + {adultContentUIDisabledOnIOS && ( 366 392 <View style={[a.pb_lg, a.px_lg]}> 367 393 <Text> 368 394 <Trans>