mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

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

at vouch-impl 172 lines 5.6 kB view raw
1import {View} from 'react-native' 2import {ModerationCause} from '@atproto/api' 3import {msg, Trans} from '@lingui/macro' 4import {useLingui} from '@lingui/react' 5 6import {useModerationCauseDescription} from '#/lib/moderation/useModerationCauseDescription' 7import {makeProfileLink} from '#/lib/routes/links' 8import {listUriToHref} from '#/lib/strings/url-helpers' 9import {isNative} from '#/platform/detection' 10import {useSession} from '#/state/session' 11import {atoms as a, useTheme} from '#/alf' 12import * as Dialog from '#/components/Dialog' 13import {Divider} from '#/components/Divider' 14import {InlineLinkText} from '#/components/Link' 15import {AppModerationCause} from '#/components/Pills' 16import {Text} from '#/components/Typography' 17 18export {useDialogControl as useModerationDetailsDialogControl} from '#/components/Dialog' 19 20export interface ModerationDetailsDialogProps { 21 control: Dialog.DialogOuterProps['control'] 22 modcause?: ModerationCause | AppModerationCause 23} 24 25export function ModerationDetailsDialog(props: ModerationDetailsDialogProps) { 26 return ( 27 <Dialog.Outer control={props.control}> 28 <Dialog.Handle /> 29 <ModerationDetailsDialogInner {...props} /> 30 </Dialog.Outer> 31 ) 32} 33 34function ModerationDetailsDialogInner({ 35 modcause, 36 control, 37}: ModerationDetailsDialogProps & { 38 control: Dialog.DialogOuterProps['control'] 39}) { 40 const t = useTheme() 41 const {_} = useLingui() 42 const desc = useModerationCauseDescription(modcause) 43 const {currentAccount} = useSession() 44 45 let name 46 let description 47 if (!modcause) { 48 name = _(msg`Content Warning`) 49 description = _( 50 msg`Moderator has chosen to set a general warning on the content.`, 51 ) 52 } else if (modcause.type === 'blocking') { 53 if (modcause.source.type === 'list') { 54 const list = modcause.source.list 55 name = _(msg`User Blocked by List`) 56 description = ( 57 <Trans> 58 This user is included in the{' '} 59 <InlineLinkText 60 label={list.name} 61 to={listUriToHref(list.uri)} 62 style={[a.text_sm]}> 63 {list.name} 64 </InlineLinkText>{' '} 65 list which you have blocked. 66 </Trans> 67 ) 68 } else { 69 name = _(msg`User Blocked`) 70 description = _( 71 msg`You have blocked this user. You cannot view their content.`, 72 ) 73 } 74 } else if (modcause.type === 'blocked-by') { 75 name = _(msg`User Blocks You`) 76 description = _( 77 msg`This user has blocked you. You cannot view their content.`, 78 ) 79 } else if (modcause.type === 'block-other') { 80 name = _(msg`Content Not Available`) 81 description = _( 82 msg`This content is not available because one of the users involved has blocked the other.`, 83 ) 84 } else if (modcause.type === 'muted') { 85 if (modcause.source.type === 'list') { 86 const list = modcause.source.list 87 name = _(msg`Account Muted by List`) 88 description = ( 89 <Trans> 90 This user is included in the{' '} 91 <InlineLinkText 92 label={list.name} 93 to={listUriToHref(list.uri)} 94 style={[a.text_sm]}> 95 {list.name} 96 </InlineLinkText>{' '} 97 list which you have muted. 98 </Trans> 99 ) 100 } else { 101 name = _(msg`Account Muted`) 102 description = _(msg`You have muted this account.`) 103 } 104 } else if (modcause.type === 'mute-word') { 105 name = _(msg`Post Hidden by Muted Word`) 106 description = _(msg`You've chosen to hide a word or tag within this post.`) 107 } else if (modcause.type === 'hidden') { 108 name = _(msg`Post Hidden by You`) 109 description = _(msg`You have hidden this post.`) 110 } else if (modcause.type === 'reply-hidden') { 111 const isYou = currentAccount?.did === modcause.source.did 112 name = isYou 113 ? _(msg`Reply Hidden by You`) 114 : _(msg`Reply Hidden by Thread Author`) 115 description = isYou 116 ? _(msg`You hid this reply.`) 117 : _(msg`The author of this thread has hidden this reply.`) 118 } else if (modcause.type === 'label') { 119 name = desc.name 120 description = ( 121 <Text emoji style={[t.atoms.text, a.text_md, a.leading_snug]}> 122 {desc.description} 123 </Text> 124 ) 125 } else { 126 // should never happen 127 name = '' 128 description = '' 129 } 130 131 return ( 132 <Dialog.ScrollableInner label={_(msg`Moderation details`)}> 133 <Text emoji style={[t.atoms.text, a.text_2xl, a.font_bold, a.mb_sm]}> 134 {name} 135 </Text> 136 <Text style={[t.atoms.text, a.text_md, a.leading_snug]}> 137 {description} 138 </Text> 139 140 {modcause?.type === 'label' && ( 141 <View style={[a.pt_lg]}> 142 <Divider /> 143 {modcause.source.type === 'user' ? ( 144 <Text style={[t.atoms.text, a.text_md, a.leading_snug, a.mt_lg]}> 145 <Trans>This label was applied by the author.</Trans> 146 </Text> 147 ) : ( 148 <> 149 <Text style={[t.atoms.text, a.text_md, a.leading_snug, a.mt_lg]}> 150 <Trans> 151 This label was applied by{' '} 152 <InlineLinkText 153 label={desc.source || _(msg`an unknown labeler`)} 154 to={makeProfileLink({did: modcause.label.src, handle: ''})} 155 onPress={() => control.close()} 156 style={a.text_md}> 157 {desc.source || _(msg`an unknown labeler`)} 158 </InlineLinkText> 159 . 160 </Trans> 161 </Text> 162 </> 163 )} 164 </View> 165 )} 166 167 {isNative && <View style={{height: 40}} />} 168 169 <Dialog.Close /> 170 </Dialog.ScrollableInner> 171 ) 172}