Only load threadgate for threads
This commit is contained in:
@@ -411,6 +411,7 @@ let PostThreadItemLoaded = ({
|
||||
onPressReply={onPressReply}
|
||||
logContext="PostThreadItem"
|
||||
rootPostUri={rootUri}
|
||||
threadgateRecord={threadgateRecord ?? undefined}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
@@ -564,6 +565,7 @@ let PostThreadItemLoaded = ({
|
||||
onPressReply={onPressReply}
|
||||
logContext="PostThreadItem"
|
||||
rootPostUri={rootUri}
|
||||
threadgateRecord={threadgateRecord ?? undefined}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -9,6 +9,7 @@ import * as Clipboard from 'expo-clipboard'
|
||||
import {
|
||||
AppBskyFeedDefs,
|
||||
AppBskyFeedPost,
|
||||
AppBskyFeedThreadgate,
|
||||
AtUri,
|
||||
RichText as RichTextAPI,
|
||||
} from '@atproto/api'
|
||||
@@ -34,7 +35,6 @@ import {
|
||||
import {useToggleQuoteDetachmentMutation} from '#/state/queries/postgate'
|
||||
import {getMaybeDetachedQuoteEmbed} from '#/state/queries/postgate/util'
|
||||
import {useToggleReplyVisibilityMutation} from '#/state/queries/threadgate'
|
||||
import {useThreadgateRecordQuery} from '#/state/queries/threadgate'
|
||||
import {useSession} from '#/state/session'
|
||||
import {getCurrentRoute} from 'lib/routes/helpers'
|
||||
import {shareUrl} from 'lib/sharing'
|
||||
@@ -80,6 +80,7 @@ let PostDropdownBtn = ({
|
||||
size,
|
||||
timestamp,
|
||||
rootPostUri,
|
||||
threadgateRecord,
|
||||
}: {
|
||||
testID: string
|
||||
post: Shadow<AppBskyFeedDefs.PostView>
|
||||
@@ -91,6 +92,7 @@ let PostDropdownBtn = ({
|
||||
size?: 'lg' | 'md' | 'sm'
|
||||
timestamp: string
|
||||
rootPostUri?: string
|
||||
threadgateRecord?: AppBskyFeedThreadgate.Record
|
||||
}): React.ReactNode => {
|
||||
const {hasSession, currentAccount} = useSession()
|
||||
const theme = useTheme()
|
||||
@@ -134,11 +136,8 @@ let PostDropdownBtn = ({
|
||||
)
|
||||
const isPostHidden = hiddenPosts && hiddenPosts.includes(postUri)
|
||||
const isAuthor = postAuthor.did === currentAccount?.did
|
||||
|
||||
const {data: threadgate} = useThreadgateRecordQuery({
|
||||
postUri: rootUri,
|
||||
})
|
||||
const isReplyHiddenByThreadgate = threadgate?.hiddenReplies?.includes(postUri)
|
||||
const isReplyHiddenByThreadgate =
|
||||
threadgateRecord?.hiddenReplies?.includes(postUri)
|
||||
|
||||
const {mutateAsync: toggleQuoteDetachment, isPending} =
|
||||
useToggleQuoteDetachmentMutation()
|
||||
@@ -270,6 +269,7 @@ let PostDropdownBtn = ({
|
||||
)
|
||||
|
||||
const onToggleReplyVisibility = React.useCallback(async () => {
|
||||
// TODO no threadgate?
|
||||
if (!rootPostUri) return
|
||||
|
||||
const action = isReplyHiddenByThreadgate ? 'show' : 'hide'
|
||||
|
||||
@@ -10,6 +10,7 @@ import * as Clipboard from 'expo-clipboard'
|
||||
import {
|
||||
AppBskyFeedDefs,
|
||||
AppBskyFeedPost,
|
||||
AppBskyFeedThreadgate,
|
||||
AtUri,
|
||||
RichText as RichTextAPI,
|
||||
} from '@atproto/api'
|
||||
@@ -60,6 +61,7 @@ let PostCtrls = ({
|
||||
onPressReply,
|
||||
logContext,
|
||||
rootPostUri,
|
||||
threadgateRecord,
|
||||
}: {
|
||||
big?: boolean
|
||||
post: Shadow<AppBskyFeedDefs.PostView>
|
||||
@@ -70,6 +72,7 @@ let PostCtrls = ({
|
||||
onPressReply: () => void
|
||||
logContext: 'FeedItem' | 'PostThreadItem' | 'Post'
|
||||
rootPostUri?: string
|
||||
threadgateRecord?: AppBskyFeedThreadgate.Record
|
||||
}): React.ReactNode => {
|
||||
const t = useTheme()
|
||||
const {_} = useLingui()
|
||||
@@ -341,6 +344,7 @@ let PostCtrls = ({
|
||||
hitSlop={POST_CTRL_HITSLOP}
|
||||
timestamp={post.indexedAt}
|
||||
rootPostUri={rootPostUri}
|
||||
threadgateRecord={threadgateRecord}
|
||||
/>
|
||||
</View>
|
||||
{gate('debug_show_feedcontext') && feedContext && (
|
||||
|
||||
Reference in New Issue
Block a user