diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 354a9f4cb..9a36f3d25 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -318,6 +318,27 @@ async function postCommunity( if (labels) { submitBody.labels = labels } + // Interaction gates: root posts only for threadgates, community $types. + if (!reply && thread.threadgate.some(tg => tg.type !== 'everybody')) { + submitBody.threadgateAllow = ( + threadgateAllowUISettingToAllowRecordValue(thread.threadgate) ?? [] + ).map(rule => ({ + ...rule, + $type: String(rule.$type).replace( + 'app.bsky.feed.threadgate', + 'community.blacksky.feed.threadgate', + ), + })) + } + if (thread.postgate.embeddingRules?.length) { + submitBody.embeddingRules = thread.postgate.embeddingRules.map(rule => ({ + ...rule, + $type: (rule.$type as string).replace( + 'app.bsky.feed.postgate', + 'community.blacksky.feed.postgate', + ), + })) + } try { const submitRes = await communityXrpc( diff --git a/src/lib/routes/types.ts b/src/lib/routes/types.ts index ff036627d..e66175004 100644 --- a/src/lib/routes/types.ts +++ b/src/lib/routes/types.ts @@ -23,9 +23,9 @@ export type CommonNavigatorParams = { ProfileSearch: {name: string; q?: string} ProfileList: {name: string; rkey: string} PostThread: {name: string; rkey: string; collection?: string} - PostLikedBy: {name: string; rkey: string} - PostRepostedBy: {name: string; rkey: string} - PostQuotes: {name: string; rkey: string} + PostLikedBy: {name: string; rkey: string; collection?: string} + PostRepostedBy: {name: string; rkey: string; collection?: string} + PostQuotes: {name: string; rkey: string; collection?: string} ProfileFeed: { name: string rkey: string diff --git a/src/screens/Post/PostLikedBy.tsx b/src/screens/Post/PostLikedBy.tsx index 2716e6318..c44047a90 100644 --- a/src/screens/Post/PostLikedBy.tsx +++ b/src/screens/Post/PostLikedBy.tsx @@ -11,8 +11,8 @@ import * as Layout from '#/components/Layout' type Props = NativeStackScreenProps export const PostLikedByScreen = ({route}: Props) => { - const {name, rkey} = route.params - const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey) + const {name, rkey, collection} = route.params + const uri = makeRecordUri(name, collection || 'app.bsky.feed.post', rkey) const {data: post} = usePostQuery(uri) let likeCount diff --git a/src/screens/Post/PostQuotes.tsx b/src/screens/Post/PostQuotes.tsx index b44028f6f..7328c6ad9 100644 --- a/src/screens/Post/PostQuotes.tsx +++ b/src/screens/Post/PostQuotes.tsx @@ -11,8 +11,8 @@ import * as Layout from '#/components/Layout' type Props = NativeStackScreenProps export const PostQuotesScreen = ({route}: Props) => { - const {name, rkey} = route.params - const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey) + const {name, rkey, collection} = route.params + const uri = makeRecordUri(name, collection || 'app.bsky.feed.post', rkey) const {data: post} = usePostQuery(uri) let quoteCount diff --git a/src/screens/Post/PostRepostedBy.tsx b/src/screens/Post/PostRepostedBy.tsx index 07082af0b..40a7beb7e 100644 --- a/src/screens/Post/PostRepostedBy.tsx +++ b/src/screens/Post/PostRepostedBy.tsx @@ -11,8 +11,8 @@ import * as Layout from '#/components/Layout' type Props = NativeStackScreenProps export const PostRepostedByScreen = ({route}: Props) => { - const {name, rkey} = route.params - const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey) + const {name, rkey, collection} = route.params + const uri = makeRecordUri(name, collection || 'app.bsky.feed.post', rkey) const {data: post} = usePostQuery(uri) let quoteCount diff --git a/src/screens/PostThread/components/ThreadItemAnchor.tsx b/src/screens/PostThread/components/ThreadItemAnchor.tsx index bb2c19594..6e178ad3c 100644 --- a/src/screens/PostThread/components/ThreadItemAnchor.tsx +++ b/src/screens/PostThread/components/ThreadItemAnchor.tsx @@ -1,4 +1,4 @@ -import {memo, useMemo} from 'react' +import {useCallback, memo, useMemo} from 'react' import {Text as RNText, View} from 'react-native' import { AppBskyFeedDefs, @@ -200,18 +200,19 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({ const authorHref = makeProfileLink(post.author) const isThreadAuthor = getThreadAuthor(post, record) === currentAccount?.did - const likesHref = useMemo(() => { - const urip = new AtUri(post.uri) - return makeProfileLink(post.author, 'post', urip.rkey, 'liked-by') - }, [post.uri, post.author]) - const repostsHref = useMemo(() => { - const urip = new AtUri(post.uri) - return makeProfileLink(post.author, 'post', urip.rkey, 'reposted-by') - }, [post.uri, post.author]) - const quotesHref = useMemo(() => { - const urip = new AtUri(post.uri) - return makeProfileLink(post.author, 'post', urip.rkey, 'quotes') - }, [post.uri, post.author]) + const statHref = useCallback( + (suffix: string) => { + const urip = new AtUri(post.uri) + const link = makeProfileLink(post.author, 'post', urip.rkey, suffix) + return urip.collection === 'community.blacksky.feed.post' + ? `${link}?collection=${urip.collection}` + : link + }, + [post.uri, post.author], + ) + const likesHref = useMemo(() => statHref('liked-by'), [statHref]) + const repostsHref = useMemo(() => statHref('reposted-by'), [statHref]) + const quotesHref = useMemo(() => statHref('quotes'), [statHref]) const threadgateHiddenReplies = useMergedThreadgateHiddenReplies({ threadgateRecord, diff --git a/src/state/queries/community-feed.ts b/src/state/queries/community-feed.ts index 4c9bb0d4c..544306bf0 100644 --- a/src/state/queries/community-feed.ts +++ b/src/state/queries/community-feed.ts @@ -206,6 +206,15 @@ export function useCommunityFeedSlices( // thread view. Stands in for followedRepliesOnly, which would pass // everything here since the whole community is "followed". const surfaced = feedItems.filter(item => { + // Blocked/muted authors never surface, same as the Following feed. + const authorViewer = item.post.author.viewer + if ( + authorViewer?.blocking || + authorViewer?.blockedBy || + authorViewer?.muted + ) { + return false + } const reply = (item.post.record as AppBskyFeedPost.Record)?.reply if (!reply?.root?.uri) return true return new AtUri(reply.root.uri).host === item.post.author.did