Bluesky app fork with some witchin' additions 馃挮
at linkat-integration 99 lines 2.5 kB view raw
1import {type ReactElement} from 'react' 2import {View} from 'react-native' 3import {type ComAtprotoServerDescribeServer} from '@atproto/api' 4import {msg, Trans} from '@lingui/macro' 5import {useLingui} from '@lingui/react' 6 7import {atoms as a, useTheme} from '#/alf' 8import {Admonition} from '#/components/Admonition' 9import {InlineLinkText} from '#/components/Link' 10import {Text} from '#/components/Typography' 11 12export const Policies = ({ 13 serviceDescription, 14}: { 15 serviceDescription: ComAtprotoServerDescribeServer.OutputSchema 16}) => { 17 const t = useTheme() 18 const {_} = useLingui() 19 20 if (!serviceDescription) { 21 return <View /> 22 } 23 24 const tos = validWebLink(serviceDescription.links?.termsOfService) 25 const pp = validWebLink(serviceDescription.links?.privacyPolicy) 26 27 if (!tos && !pp) { 28 return ( 29 <View style={[a.gap_sm]}> 30 <Admonition type="info"> 31 <Trans> 32 This service has not provided terms of service or a privacy policy. 33 </Trans> 34 </Admonition> 35 </View> 36 ) 37 } 38 39 let els: ReactElement<any> 40 if (tos && pp) { 41 els = ( 42 <Trans> 43 By creating an account you agree to the{' '} 44 <InlineLinkText 45 label={_(msg`Read the Bluesky Terms of Service`)} 46 key="tos" 47 to={tos}> 48 Terms of Service 49 </InlineLinkText>{' '} 50 and{' '} 51 <InlineLinkText 52 label={_(msg`Read the Bluesky Privacy Policy`)} 53 key="pp" 54 to={pp}> 55 Privacy Policy 56 </InlineLinkText> 57 . 58 </Trans> 59 ) 60 } else if (tos) { 61 els = ( 62 <Trans> 63 By creating an account you agree to the{' '} 64 <InlineLinkText 65 label={_(msg`Read the Bluesky Terms of Service`)} 66 key="tos" 67 to={tos}> 68 Terms of Service 69 </InlineLinkText> 70 . 71 </Trans> 72 ) 73 } else if (pp) { 74 els = ( 75 <Trans> 76 By creating an account you agree to the{' '} 77 <InlineLinkText 78 label={_(msg`Read the Bluesky Privacy Policy`)} 79 key="pp" 80 to={pp}> 81 Privacy Policy 82 </InlineLinkText> 83 . 84 </Trans> 85 ) 86 } else { 87 return null 88 } 89 90 return els ? ( 91 <Text style={[a.leading_snug, t.atoms.text_contrast_medium]}>{els}</Text> 92 ) : null 93} 94 95function validWebLink(url?: string): string | undefined { 96 return url && (url.startsWith('http://') || url.startsWith('https://')) 97 ? url 98 : undefined 99}