Prep threadgate shadow hack (#4970)

Co-authored-by: Hailey <me@haileyok.com>
This commit is contained in:
Eric Bailey 2024-08-21 22:16:03 -05:00 committed by GitHub
parent 61f0be705d
commit d5c78b9183
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 68 additions and 23 deletions

View file

@ -129,17 +129,18 @@ export function PostThread({uri}: {uri: string | undefined}) {
currentAccount &&
rootPostUri &&
currentAccount?.did === new AtUri(rootPostUri).host
const initialThreadgateRecord = rootPost?.threadgate?.record as
| AppBskyFeedThreadgate.Record
| undefined
const {data: threadgateRecord} = useThreadgateRecordQuery({
/**
* If the user is the OP and the root post has a threadgate, we should load
* the threadgate record. Otherwise, fallback to initialData, which is taken
* from the response from `getPostThread`.
*/
enabled: Boolean(isOP && rootPostUri),
enabled: Boolean(isOP && rootPostUri && initialThreadgateRecord),
postUri: rootPostUri,
initialData: rootPost?.threadgate?.record as
| AppBskyFeedThreadgate.Record
| undefined,
initialData: initialThreadgateRecord,
})
const moderationOpts = useModerationOpts()

View file

@ -399,22 +399,6 @@ let PostThreadItemLoaded = ({
</Text>
</Link>
) : null}
{post.likeCount != null && post.likeCount !== 0 ? (
<Link
style={styles.expandedInfoItem}
href={likesHref}
title={likesTitle}>
<Text
testID="likeCount-expanded"
type="lg"
style={pal.textLight}>
<Text type="xl-bold" style={pal.text}>
{formatCount(post.likeCount)}
</Text>{' '}
<Plural value={post.likeCount} one="like" other="likes" />
</Text>
</Link>
) : null}
{post.quoteCount != null && post.quoteCount !== 0 ? (
<Link
style={styles.expandedInfoItem}
@ -435,6 +419,22 @@ let PostThreadItemLoaded = ({
</Text>
</Link>
) : null}
{post.likeCount != null && post.likeCount !== 0 ? (
<Link
style={styles.expandedInfoItem}
href={likesHref}
title={likesTitle}>
<Text
testID="likeCount-expanded"
type="lg"
style={pal.textLight}>
<Text type="xl-bold" style={pal.text}>
{formatCount(post.likeCount)}
</Text>{' '}
<Plural value={post.likeCount} one="like" other="likes" />
</Text>
</Link>
) : null}
</View>
) : null}
<View style={[s.pl10, s.pr10]}>

View file

@ -255,7 +255,7 @@ let PostCtrls = ({
<View style={big ? a.align_center : [a.flex_1, a.align_start]}>
<RepostButton
isReposted={!!post.viewer?.repost}
repostCount={post.repostCount}
repostCount={(post.repostCount ?? 0) + (post.quoteCount ?? 0)}
onRepost={onRepost}
onQuote={onQuote}
big={big}