Integrate postgate into WhoCanReply text

This commit is contained in:
Eric Bailey
2024-08-09 16:33:50 -05:00
parent 045c511196
commit f7eb2b4031
2 changed files with 90 additions and 82 deletions
+49 -38
View File
@@ -35,8 +35,8 @@ import {useDialogControl} from '#/components/Dialog'
import {CircleBanSign_Stroke2_Corner0_Rounded as CircleBanSign} from '#/components/icons/CircleBanSign' import {CircleBanSign_Stroke2_Corner0_Rounded as CircleBanSign} from '#/components/icons/CircleBanSign'
import {Earth_Stroke2_Corner0_Rounded as Earth} from '#/components/icons/Globe' import {Earth_Stroke2_Corner0_Rounded as Earth} from '#/components/icons/Globe'
import {Group3_Stroke2_Corner0_Rounded as Group} from '#/components/icons/Group' import {Group3_Stroke2_Corner0_Rounded as Group} from '#/components/icons/Group'
import {InlineLinkText} from '#/components/Link'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import {TextLink} from '../view/com/util/Link'
import {PostInteractionSettingsDialog} from './dialogs/PostInteractionSettingsDialog' import {PostInteractionSettingsDialog} from './dialogs/PostInteractionSettingsDialog'
import {PencilLine_Stroke2_Corner0_Rounded as PencilLine} from './icons/Pencil' import {PencilLine_Stroke2_Corner0_Rounded as PencilLine} from './icons/Pencil'
@@ -231,6 +231,7 @@ export function WhoCanReply({
control={infoDialogControl} control={infoDialogControl}
post={post} post={post}
settings={settings} settings={settings}
postgate={postgate}
/> />
)} )}
</> </>
@@ -256,61 +257,58 @@ function WhoCanReplyDialog({
control, control,
post, post,
settings, settings,
postgate,
}: { }: {
control: Dialog.DialogControlProps control: Dialog.DialogControlProps
post: AppBskyFeedDefs.PostView post: AppBskyFeedDefs.PostView
settings: ThreadgateAllowUISetting[] settings: ThreadgateAllowUISetting[]
}) { postgate: AppBskyFeedPostgate.Record
return (
<Dialog.Outer control={control}>
<Dialog.Handle />
<WhoCanReplyDialogInner post={post} settings={settings} />
</Dialog.Outer>
)
}
function WhoCanReplyDialogInner({
post,
settings,
}: {
post: AppBskyFeedDefs.PostView
settings: ThreadgateAllowUISetting[]
}) { }) {
const {_} = useLingui() const {_} = useLingui()
return ( return (
<Dialog.Outer control={control}>
<Dialog.Handle />
<Dialog.ScrollableInner <Dialog.ScrollableInner
label={_(msg`Who can reply dialog`)} label={_(msg`Who can reply dialog`)}
style={[{width: 'auto', maxWidth: 400, minWidth: 200}]}> style={[{width: 'auto', maxWidth: 400, minWidth: 200}]}>
<View style={[a.gap_sm]}> <View style={[a.gap_sm]}>
<Text style={[a.font_bold, a.text_xl]}> <Text style={[a.font_bold, a.text_xl, a.pb_sm]}>
<Trans>Who can reply?</Trans> <Trans>Who can interact with this post?</Trans>
</Text> </Text>
<Rules post={post} settings={settings} /> <Rules post={post} settings={settings} postgate={postgate} />
</View> </View>
</Dialog.ScrollableInner> </Dialog.ScrollableInner>
</Dialog.Outer>
) )
} }
function Rules({ function Rules({
post, post,
settings, settings,
postgate,
}: { }: {
post: AppBskyFeedDefs.PostView post: AppBskyFeedDefs.PostView
settings: ThreadgateAllowUISetting[] settings: ThreadgateAllowUISetting[]
postgate: AppBskyFeedPostgate.Record
}) { }) {
const t = useTheme() const t = useTheme()
const noOneCanQuote =
postgate.quotepostRules?.length === 1 &&
postgate.quotepostRules[0]?.$type === embeddingRules.disableRule.$type
return ( return (
<>
<Text <Text
style={[ style={[
a.text_md, a.text_sm,
a.leading_tight, a.leading_snug,
a.flex_wrap, a.flex_wrap,
t.atoms.text_contrast_medium, t.atoms.text_contrast_medium,
]}> ]}>
{!settings.length ? ( {settings[0].type === 'everybody' ? (
<Trans>Everybody can reply</Trans> <Trans>Everybody can reply to this post.</Trans>
) : settings[0].type === 'nobody' ? ( ) : settings[0].type === 'nobody' ? (
<Trans>Replies to this thread are disabled</Trans> <Trans>Replies to this post are disabled</Trans>
) : ( ) : (
<Trans> <Trans>
Only{' '} Only{' '}
@@ -325,10 +323,24 @@ function Rules({
<Separator key={`sep-${i}`} i={i} length={settings.length} /> <Separator key={`sep-${i}`} i={i} length={settings.length} />
</> </>
))}{' '} ))}{' '}
can reply can reply.
</Trans> </Trans>
)}{' '}
</Text>
<Text
style={[
a.text_sm,
a.leading_snug,
a.flex_wrap,
t.atoms.text_contrast_medium,
]}>
{noOneCanQuote ? (
<Trans>No one but the author can quote this post.</Trans>
) : (
<Trans>Anyone can quote this post.</Trans>
)} )}
</Text> </Text>
</>
) )
} }
@@ -341,7 +353,6 @@ function Rule({
post: AppBskyFeedDefs.PostView post: AppBskyFeedDefs.PostView
lists: AppBskyGraphDefs.ListViewBasic[] | undefined lists: AppBskyGraphDefs.ListViewBasic[] | undefined
}) { }) {
const t = useTheme()
if (rule.type === 'mention') { if (rule.type === 'mention') {
return <Trans>mentioned users</Trans> return <Trans>mentioned users</Trans>
} }
@@ -349,12 +360,12 @@ function Rule({
return ( return (
<Trans> <Trans>
users followed by{' '} users followed by{' '}
<TextLink <InlineLinkText
type="sm" label={`@${post.author.handle}`}
href={makeProfileLink(post.author)} to={makeProfileLink(post.author)}
text={`@${post.author.handle}`} style={[a.text_sm, a.leading_snug]}>
style={{color: t.palette.primary_500}} @{post.author.handle}
/> </InlineLinkText>
</Trans> </Trans>
) )
} }
@@ -364,12 +375,12 @@ function Rule({
const listUrip = new AtUri(list.uri) const listUrip = new AtUri(list.uri)
return ( return (
<Trans> <Trans>
<TextLink <InlineLinkText
type="sm" label={list.name}
href={makeListLink(listUrip.hostname, listUrip.rkey)} to={makeListLink(listUrip.hostname, listUrip.rkey)}
text={list.name} style={[a.text_sm, a.leading_snug]}>
style={{color: t.palette.primary_500}} {list.name}
/>{' '} </InlineLinkText>{' '}
members members
</Trans> </Trans>
) )
@@ -683,7 +683,6 @@ function ExpandedPostDetails({
const pal = usePalette('default') const pal = usePalette('default')
const {_} = useLingui() const {_} = useLingui()
const openLink = useOpenLink() const openLink = useOpenLink()
const isRootPost = !('reply' in post.record)
const onTranslatePress = React.useCallback(() => { const onTranslatePress = React.useCallback(() => {
openLink(translatorUrl) openLink(translatorUrl)
@@ -700,7 +699,6 @@ function ExpandedPostDetails({
s.mb10, s.mb10,
]}> ]}>
<Text style={[a.text_sm, pal.textLight]}>{niceDate(post.indexedAt)}</Text> <Text style={[a.text_sm, pal.textLight]}>{niceDate(post.indexedAt)}</Text>
{isRootPost && (
<WhoCanReply <WhoCanReply
post={post} post={post}
postgate={ postgate={
@@ -712,7 +710,6 @@ function ExpandedPostDetails({
} }
isThreadAuthor={isThreadAuthor} isThreadAuthor={isThreadAuthor}
/> />
)}
{needsTranslation && ( {needsTranslation && (
<> <>
<Text style={[a.text_sm, pal.textLight]}>&middot;</Text> <Text style={[a.text_sm, pal.textLight]}>&middot;</Text>