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