Integrate postgate into WhoCanReply text
This commit is contained in:
@@ -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,79 +257,90 @@ 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.ScrollableInner
|
<Dialog.Outer control={control}>
|
||||||
label={_(msg`Who can reply dialog`)}
|
<Dialog.Handle />
|
||||||
style={[{width: 'auto', maxWidth: 400, minWidth: 200}]}>
|
<Dialog.ScrollableInner
|
||||||
<View style={[a.gap_sm]}>
|
label={_(msg`Who can reply dialog`)}
|
||||||
<Text style={[a.font_bold, a.text_xl]}>
|
style={[{width: 'auto', maxWidth: 400, minWidth: 200}]}>
|
||||||
<Trans>Who can reply?</Trans>
|
<View style={[a.gap_sm]}>
|
||||||
</Text>
|
<Text style={[a.font_bold, a.text_xl, a.pb_sm]}>
|
||||||
<Rules post={post} settings={settings} />
|
<Trans>Who can interact with this post?</Trans>
|
||||||
</View>
|
</Text>
|
||||||
</Dialog.ScrollableInner>
|
<Rules post={post} settings={settings} postgate={postgate} />
|
||||||
|
</View>
|
||||||
|
</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
|
<>
|
||||||
style={[
|
<Text
|
||||||
a.text_md,
|
style={[
|
||||||
a.leading_tight,
|
a.text_sm,
|
||||||
a.flex_wrap,
|
a.leading_snug,
|
||||||
t.atoms.text_contrast_medium,
|
a.flex_wrap,
|
||||||
]}>
|
t.atoms.text_contrast_medium,
|
||||||
{!settings.length ? (
|
]}>
|
||||||
<Trans>Everybody can reply</Trans>
|
{settings[0].type === 'everybody' ? (
|
||||||
) : settings[0].type === 'nobody' ? (
|
<Trans>Everybody can reply to this post.</Trans>
|
||||||
<Trans>Replies to this thread are disabled</Trans>
|
) : settings[0].type === 'nobody' ? (
|
||||||
) : (
|
<Trans>Replies to this post are disabled</Trans>
|
||||||
<Trans>
|
) : (
|
||||||
Only{' '}
|
<Trans>
|
||||||
{settings.map((rule, i) => (
|
Only{' '}
|
||||||
<>
|
{settings.map((rule, i) => (
|
||||||
<Rule
|
<>
|
||||||
key={`rule-${i}`}
|
<Rule
|
||||||
rule={rule}
|
key={`rule-${i}`}
|
||||||
post={post}
|
rule={rule}
|
||||||
lists={post.threadgate!.lists}
|
post={post}
|
||||||
/>
|
lists={post.threadgate!.lists}
|
||||||
<Separator key={`sep-${i}`} i={i} length={settings.length} />
|
/>
|
||||||
</>
|
<Separator key={`sep-${i}`} i={i} length={settings.length} />
|
||||||
))}{' '}
|
</>
|
||||||
can reply
|
))}{' '}
|
||||||
</Trans>
|
can reply.
|
||||||
)}
|
</Trans>
|
||||||
</Text>
|
)}{' '}
|
||||||
|
</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>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,19 +699,17 @@ 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={
|
// TODO maybe define at query
|
||||||
// TODO maybe define at query
|
postgate ||
|
||||||
postgate ||
|
createPostgateRecord({
|
||||||
createPostgateRecord({
|
post: post.uri,
|
||||||
post: post.uri,
|
})
|
||||||
})
|
}
|
||||||
}
|
isThreadAuthor={isThreadAuthor}
|
||||||
isThreadAuthor={isThreadAuthor}
|
/>
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{needsTranslation && (
|
{needsTranslation && (
|
||||||
<>
|
<>
|
||||||
<Text style={[a.text_sm, pal.textLight]}>·</Text>
|
<Text style={[a.text_sm, pal.textLight]}>·</Text>
|
||||||
|
|||||||
Reference in New Issue
Block a user