diff --git a/src/components/CommunityFeed.tsx b/src/components/CommunityFeed.tsx
new file mode 100644
index 000000000..30fec5a58
--- /dev/null
+++ b/src/components/CommunityFeed.tsx
@@ -0,0 +1,127 @@
+import React from 'react'
+import {ActivityIndicator, View} from 'react-native'
+import {
+ type AppBskyFeedDefs,
+ type AppBskyFeedPost,
+ RichText as RichTextAPI,
+} from '@atproto/api'
+import {Trans} from '@lingui/macro'
+
+import {useCommunityFeedQuery} from '#/state/queries/community-feed'
+import {TimeElapsed} from '#/view/com/util/TimeElapsed'
+import {atoms as a, useTheme} from '#/alf'
+import {RichText} from '#/components/RichText'
+import {Text} from '#/components/Typography'
+
+export function CommunityFeed({actor}: {actor: string}) {
+ const t = useTheme()
+ const {
+ data,
+ isLoading,
+ isError,
+ hasNextPage,
+ fetchNextPage,
+ isFetchingNextPage,
+ } = useCommunityFeedQuery(actor)
+
+ if (isLoading) {
+ return (
+
+
+
+ )
+ }
+
+ if (isError) {
+ return (
+
+
+ Failed to load community posts
+
+
+ )
+ }
+
+ const feedItems = data?.pages.flatMap(page => page.feed) || []
+
+ if (feedItems.length === 0) {
+ return (
+
+
+ No community posts yet
+
+
+ )
+ }
+
+ return (
+
+
+
+ Blacksky Community Posts
+
+
+ {feedItems.map(item => (
+
+ ))}
+ {hasNextPage && (
+
+ {isFetchingNextPage ? (
+
+ ) : (
+ fetchNextPage()}>
+ Load more
+
+ )}
+
+ )}
+
+ )
+}
+
+export function CommunityPostItem({
+ postView,
+}: {
+ postView: AppBskyFeedDefs.PostView
+}) {
+ const t = useTheme()
+ const record = postView.record as AppBskyFeedPost.Record
+ const rt = React.useMemo(() => {
+ const richText = new RichTextAPI({
+ text: record.text,
+ facets: record.facets,
+ })
+ return richText
+ }, [record.text, record.facets])
+
+ return (
+
+
+
+ Community
+
+
+ {({timeElapsed}) => (
+
+ {timeElapsed}
+
+ )}
+
+ {(postView.replyCount ?? 0) > 0 && (
+
+ {postView.replyCount} replies
+
+ )}
+
+
+
+ )
+}
diff --git a/src/components/Post/Embed/index.tsx b/src/components/Post/Embed/index.tsx
index 7472d50ef..914ffc65c 100644
--- a/src/components/Post/Embed/index.tsx
+++ b/src/components/Post/Embed/index.tsx
@@ -327,7 +327,11 @@ export function QuoteEmbed({
const t = useTheme()
const queryClient = useQueryClient()
const itemUrip = new AtUri(quote.uri)
- const itemHref = makeProfileLink(quote.author, 'post', itemUrip.rkey)
+ const isCommunityQuote =
+ itemUrip.collection === 'community.blacksky.feed.post'
+ const itemHref = isCommunityQuote
+ ? `${makeProfileLink(quote.author, 'post', itemUrip.rkey)}?collection=${itemUrip.collection}`
+ : makeProfileLink(quote.author, 'post', itemUrip.rkey)
const itemTitle = `Post by ${quote.author.handle}`
const richText = useMemo(() => {
diff --git a/src/components/PostControls/PostMenu/PostMenuItems.tsx b/src/components/PostControls/PostMenu/PostMenuItems.tsx
index 9f18bd01a..0d7828b26 100644
--- a/src/components/PostControls/PostMenu/PostMenuItems.tsx
+++ b/src/components/PostControls/PostMenu/PostMenuItems.tsx
@@ -182,7 +182,9 @@ let PostMenuItems = ({
const href = useMemo(() => {
const urip = new AtUri(postUri)
- return makeProfileLink(postAuthor, 'post', urip.rkey)
+ const link = makeProfileLink(postAuthor, 'post', urip.rkey)
+ const isCommunity = urip.collection === 'community.blacksky.feed.post'
+ return isCommunity ? `${link}?collection=${urip.collection}` : link
}, [postUri, postAuthor])
const onDeletePost = () => {
@@ -199,7 +201,10 @@ let PostMenuItems = ({
(params.name === currentAccount.handle ||
params.name === currentAccount.did)
) {
- const currentHref = makeProfileLink(postAuthor, 'post', params.rkey)
+ const currentLink = makeProfileLink(postAuthor, 'post', params.rkey)
+ const currentHref = params.collection
+ ? `${currentLink}?collection=${params.collection}`
+ : currentLink
if (currentHref === href && navigation.canGoBack()) {
navigation.goBack()
}
diff --git a/src/components/PostControls/ShareMenu/ShareMenuItems.tsx b/src/components/PostControls/ShareMenu/ShareMenuItems.tsx
index ab9ab1eef..a7b02e547 100644
--- a/src/components/PostControls/ShareMenu/ShareMenuItems.tsx
+++ b/src/components/PostControls/ShareMenu/ShareMenuItems.tsx
@@ -47,7 +47,9 @@ let ShareMenuItems = ({
const href = useMemo(() => {
const urip = new AtUri(postUri)
- return makeProfileLink(postAuthor, 'post', urip.rkey)
+ const link = makeProfileLink(postAuthor, 'post', urip.rkey)
+ const isCommunity = urip.collection === 'community.blacksky.feed.post'
+ return isCommunity ? `${link}?collection=${urip.collection}` : link
}, [postUri, postAuthor])
const hideInPWI = useMemo(() => {
diff --git a/src/components/PostControls/ShareMenu/ShareMenuItems.web.tsx b/src/components/PostControls/ShareMenu/ShareMenuItems.web.tsx
index 2cb66b29a..963c5bb04 100644
--- a/src/components/PostControls/ShareMenu/ShareMenuItems.web.tsx
+++ b/src/components/PostControls/ShareMenu/ShareMenuItems.web.tsx
@@ -46,7 +46,9 @@ let ShareMenuItems = ({
const href = useMemo(() => {
const urip = new AtUri(postUri)
- return makeProfileLink(postAuthor, 'post', urip.rkey)
+ const link = makeProfileLink(postAuthor, 'post', urip.rkey)
+ const isCommunity = urip.collection === 'community.blacksky.feed.post'
+ return isCommunity ? `${link}?collection=${urip.collection}` : link
}, [postUri, postAuthor])
const hideInPWI = useMemo(() => {
diff --git a/src/components/PostControls/ShareMenu/index.tsx b/src/components/PostControls/ShareMenu/index.tsx
index efac6a3f0..6464d0dd3 100644
--- a/src/components/PostControls/ShareMenu/index.tsx
+++ b/src/components/PostControls/ShareMenu/index.tsx
@@ -86,7 +86,9 @@ let ShareMenuButton = ({
const onNativeLongPress = () => {
ax.metric('share:press:nativeShare', {})
const urip = new AtUri(post.uri)
- const href = makeProfileLink(post.author, 'post', urip.rkey)
+ const link = makeProfileLink(post.author, 'post', urip.rkey)
+ const isCommunity = urip.collection === 'community.blacksky.feed.post'
+ const href = isCommunity ? `${link}?collection=${urip.collection}` : link
const url = toShareUrl(href)
shareUrl(url)
onShare()
diff --git a/src/lib/api/community.ts b/src/lib/api/community.ts
new file mode 100644
index 000000000..112a69bb3
--- /dev/null
+++ b/src/lib/api/community.ts
@@ -0,0 +1,37 @@
+import {type BskyAgent} from '@atproto/api'
+
+import {BLUESKY_PROXY_HEADER} from '#/lib/constants'
+
+/**
+ * Make an XRPC call to a community.blacksky.feed.* endpoint.
+ *
+ * Calls through the PDS using the agent's session auth and atproto-proxy
+ * header. The PDS validates the user's credentials, creates a service auth
+ * JWT signed by the user's keypair, and forwards the request to the appview.
+ */
+export async function communityXrpc(
+ agent: BskyAgent,
+ method: string,
+ opts?: {
+ params?: Record
+ body?: unknown
+ },
+): Promise {
+ const qs = opts?.params
+ ? '?' + new URLSearchParams(opts.params).toString()
+ : ''
+ const path = `/xrpc/${method}${qs}`
+
+ const headers: Record = {
+ 'atproto-proxy': BLUESKY_PROXY_HEADER.get(),
+ }
+ const init: RequestInit = {
+ method: opts?.body ? 'POST' : 'GET',
+ headers,
+ }
+ if (opts?.body) {
+ headers['Content-Type'] = 'application/json'
+ init.body = JSON.stringify(opts.body)
+ }
+ return agent.fetchHandler(path, init)
+}
diff --git a/src/lib/routes/types.ts b/src/lib/routes/types.ts
index d0fbe4e6a..ff036627d 100644
--- a/src/lib/routes/types.ts
+++ b/src/lib/routes/types.ts
@@ -22,7 +22,7 @@ export type CommonNavigatorParams = {
ProfileKnownFollowers: {name: string}
ProfileSearch: {name: string; q?: string}
ProfileList: {name: string; rkey: string}
- PostThread: {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}
diff --git a/src/screens/Messages/components/MessageInputEmbed.tsx b/src/screens/Messages/components/MessageInputEmbed.tsx
index 4b69e1f67..355a9c2fb 100644
--- a/src/screens/Messages/components/MessageInputEmbed.tsx
+++ b/src/screens/Messages/components/MessageInputEmbed.tsx
@@ -204,7 +204,11 @@ function MessageInputPostEmbed({
}
case 'success': {
const itemUrip = new AtUri(post.uri)
- const itemHref = makeProfileLink(post.author, 'post', itemUrip.rkey)
+ const isCommunityPost =
+ itemUrip.collection === 'community.blacksky.feed.post'
+ const itemHref = isCommunityPost
+ ? `${makeProfileLink(post.author, 'post', itemUrip.rkey)}?collection=${itemUrip.collection}`
+ : makeProfileLink(post.author, 'post', itemUrip.rkey)
if (!post || !moderation || !rt || !record) {
return null
diff --git a/src/screens/PostThread/components/ThreadItemPost.tsx b/src/screens/PostThread/components/ThreadItemPost.tsx
index c1e27222f..5ee7d85b2 100644
--- a/src/screens/PostThread/components/ThreadItemPost.tsx
+++ b/src/screens/PostThread/components/ThreadItemPost.tsx
@@ -212,7 +212,9 @@ const ThreadItemPostInner = memo(function ThreadItemPostInner({
const threadRootUri = record.reply?.root?.uri || post.uri
const postHref = useMemo(() => {
const urip = new AtUri(post.uri)
- return makeProfileLink(post.author, 'post', urip.rkey)
+ const link = makeProfileLink(post.author, 'post', urip.rkey)
+ const isCommunity = urip.collection === 'community.blacksky.feed.post'
+ return isCommunity ? `${link}?collection=${urip.collection}` : link
}, [post.uri, post.author])
const threadgateHiddenReplies = useMergedThreadgateHiddenReplies({
threadgateRecord,
diff --git a/src/screens/PostThread/components/ThreadItemTreePost.tsx b/src/screens/PostThread/components/ThreadItemTreePost.tsx
index 986878664..c1125110b 100644
--- a/src/screens/PostThread/components/ThreadItemTreePost.tsx
+++ b/src/screens/PostThread/components/ThreadItemTreePost.tsx
@@ -274,7 +274,9 @@ const ThreadItemTreePostInner = memo(function ThreadItemTreePostInner({
const threadRootUri = record.reply?.root?.uri || post.uri
const postHref = useMemo(() => {
const urip = new AtUri(post.uri)
- return makeProfileLink(post.author, 'post', urip.rkey)
+ const link = makeProfileLink(post.author, 'post', urip.rkey)
+ const isCommunity = urip.collection === 'community.blacksky.feed.post'
+ return isCommunity ? `${link}?collection=${urip.collection}` : link
}, [post.uri, post.author])
const threadgateHiddenReplies = useMergedThreadgateHiddenReplies({
threadgateRecord,
diff --git a/src/screens/Profile/Sections/CommunityFeed.tsx b/src/screens/Profile/Sections/CommunityFeed.tsx
new file mode 100644
index 000000000..297435129
--- /dev/null
+++ b/src/screens/Profile/Sections/CommunityFeed.tsx
@@ -0,0 +1,181 @@
+import {useCallback, useEffect, useImperativeHandle, useMemo} from 'react'
+import {
+ ActivityIndicator,
+ findNodeHandle,
+ type ListRenderItemInfo,
+ View,
+} from 'react-native'
+import {msg, Trans} from '@lingui/macro'
+import {useLingui} from '@lingui/react'
+
+import {
+ type HydratedCommunityPost,
+ useCommunityFeedHydrated,
+ useCommunityFeedQuery,
+} from '#/state/queries/community-feed'
+import {PostFeedItem} from '#/view/com/posts/PostFeedItem'
+import {EmptyState} from '#/view/com/util/EmptyState'
+import {List, type ListRef} from '#/view/com/util/List'
+import {atoms as a, ios, useTheme} from '#/alf'
+import {Text} from '#/components/Typography'
+import {IS_IOS, IS_NATIVE} from '#/env'
+import {type SectionRef} from './types'
+
+interface CommunityFeedSectionProps {
+ ref?: React.Ref
+ actor: string
+ headerHeight: number
+ isFocused: boolean
+ scrollElRef: ListRef
+ setScrollViewTag: (tag: number | null) => void
+}
+
+export function CommunityFeedSection({
+ ref,
+ actor,
+ headerHeight,
+ isFocused,
+ scrollElRef,
+ setScrollViewTag,
+}: CommunityFeedSectionProps) {
+ const {_} = useLingui()
+ const t = useTheme()
+ const {
+ data,
+ isLoading,
+ isError,
+ hasNextPage,
+ fetchNextPage,
+ isFetchingNextPage,
+ refetch,
+ } = useCommunityFeedQuery(isFocused ? actor : undefined)
+
+ const feedItems = useMemo(
+ () => data?.pages.flatMap(page => page.feed ?? []) ?? [],
+ [data],
+ )
+
+ const hydratedPosts = useCommunityFeedHydrated(feedItems)
+
+ const onScrollToTop = useCallback(() => {
+ scrollElRef.current?.scrollToOffset({
+ animated: IS_NATIVE,
+ offset: -headerHeight,
+ })
+ refetch()
+ }, [scrollElRef, headerHeight, refetch])
+
+ useImperativeHandle(ref, () => ({
+ scrollToTop: onScrollToTop,
+ }))
+
+ useEffect(() => {
+ if (IS_IOS && isFocused && scrollElRef.current) {
+ const nativeTag = findNodeHandle(scrollElRef.current)
+ setScrollViewTag(nativeTag)
+ }
+ }, [isFocused, scrollElRef, setScrollViewTag])
+
+ const renderItem = useCallback(
+ ({item, index}: ListRenderItemInfo) => {
+ return (
+
+ )
+ },
+ [],
+ )
+
+ const keyExtractor = useCallback(
+ (item: HydratedCommunityPost) => item.post.uri,
+ [],
+ )
+
+ const onEndReached = useCallback(() => {
+ if (hasNextPage && !isFetchingNextPage) {
+ fetchNextPage()
+ }
+ }, [hasNextPage, isFetchingNextPage, fetchNextPage])
+
+ const renderEmpty = useCallback(() => {
+ if (isLoading) {
+ return (
+
+
+
+ )
+ }
+ if (isError) {
+ return (
+
+
+ Failed to load community posts
+
+
+ )
+ }
+ return (
+
+ )
+ }, [_, isLoading, isError, t])
+
+ const renderFooter = useCallback(() => {
+ if (isFetchingNextPage) {
+ return (
+
+
+
+ )
+ }
+ if (!hasNextPage && hydratedPosts.length > 0) {
+ return (
+
+
+ End of feed
+
+
+ )
+ }
+ return null
+ }, [isFetchingNextPage, hasNextPage, hydratedPosts.length, t])
+
+ return (
+
+
+
+ )
+}
diff --git a/src/state/cache/post-shadow.ts b/src/state/cache/post-shadow.ts
index 33e78580a..c3ccd6dbb 100644
--- a/src/state/cache/post-shadow.ts
+++ b/src/state/cache/post-shadow.ts
@@ -9,6 +9,7 @@ import {EventEmitter} from 'eventemitter3'
import {batchedUpdates} from '#/lib/batchedUpdates'
import {findAllPostsInQueryData as findAllPostsInBookmarksQueryData} from '#/state/queries/bookmarks/useBookmarksQuery'
+import {findAllPostsInQueryData as findAllPostsInCommunityFeedQueryData} from '#/state/queries/community-feed'
import {findAllPostsInQueryData as findAllPostsInExploreFeedPreviewsQueryData} from '#/state/queries/explore-feed-previews'
import {findAllPostsInQueryData as findAllPostsInNotifsQueryData} from '#/state/queries/notifications/feed'
import {findAllPostsInQueryData as findAllPostsInFeedQueryData} from '#/state/queries/post-feed'
@@ -198,4 +199,7 @@ function* findPostsInCache(
for (let post of findAllPostsInTopicQueryData(queryClient, uri)) {
yield post
}
+ for (let post of findAllPostsInCommunityFeedQueryData(queryClient, uri)) {
+ yield post
+ }
}
diff --git a/src/state/queries/community-feed.ts b/src/state/queries/community-feed.ts
new file mode 100644
index 000000000..ed769efd8
--- /dev/null
+++ b/src/state/queries/community-feed.ts
@@ -0,0 +1,221 @@
+import {useMemo} from 'react'
+import {
+ type AppBskyFeedDefs,
+ type AppBskyFeedPost,
+ AtUri,
+ moderatePost,
+ type ModerationDecision,
+} from '@atproto/api'
+import {
+ type InfiniteData,
+ type QueryClient,
+ type QueryKey,
+ useInfiniteQuery,
+ useQuery,
+} from '@tanstack/react-query'
+
+import {communityXrpc} from '#/lib/api/community'
+import {useModerationOpts} from '#/state/preferences/moderation-opts'
+import {
+ didOrHandleUriMatches,
+ embedViewRecordToPostView,
+ getEmbeddedPost,
+} from '#/state/queries/util'
+import {useAgent} from '#/state/session'
+
+const PAGE_SIZE = 30
+type RQPageParam = string | undefined
+
+export const RQKEY_ROOT = 'community-feed'
+export const RQKEY = (actor: string) => [RQKEY_ROOT, actor]
+
+const TIMELINE_RQKEY_ROOT = 'community-timeline'
+export const TIMELINE_RQKEY = () => [TIMELINE_RQKEY_ROOT]
+
+// Server returns feedViewPost format with hydrated posts
+// Support both old 'posts' format (raw) and new 'feed' format (hydrated)
+interface CommunityFeedPage {
+ cursor?: string
+ feed?: AppBskyFeedDefs.FeedViewPost[]
+ // Legacy format for backward compatibility during deployment
+ posts?: Array<{
+ uri: string
+ cid?: string
+ creator: string
+ text: string
+ createdAt: string
+ indexedAt: string
+ }>
+}
+
+export function useCommunityFeedQuery(actor: string | undefined) {
+ const agent = useAgent()
+ return useInfiniteQuery<
+ CommunityFeedPage,
+ Error,
+ InfiniteData,
+ QueryKey,
+ RQPageParam
+ >({
+ queryKey: RQKEY(actor || ''),
+ async queryFn({pageParam}: {pageParam: RQPageParam}) {
+ const params: Record = {
+ actor: actor || '',
+ limit: String(PAGE_SIZE),
+ }
+ if (pageParam) {
+ params.cursor = pageParam
+ }
+ const res = await communityXrpc(
+ agent,
+ 'community.blacksky.feed.getCommunityFeed',
+ {params},
+ )
+ if (!res.ok) {
+ throw new Error(`getCommunityFeed failed: ${res.status}`)
+ }
+ return (await res.json()) as CommunityFeedPage
+ },
+ initialPageParam: undefined,
+ getNextPageParam: lastPage => lastPage.cursor,
+ enabled: !!actor,
+ })
+}
+
+/**
+ * Query for the global community timeline (all community posts).
+ * Used on the Home screen Community tab.
+ */
+export function useCommunityTimelineQuery(enabled: boolean) {
+ const agent = useAgent()
+ return useInfiniteQuery<
+ CommunityFeedPage,
+ Error,
+ InfiniteData,
+ QueryKey,
+ RQPageParam
+ >({
+ queryKey: TIMELINE_RQKEY(),
+ async queryFn({pageParam}: {pageParam: RQPageParam}) {
+ const params: Record = {
+ limit: String(PAGE_SIZE),
+ }
+ if (pageParam) {
+ params.cursor = pageParam
+ }
+ const res = await communityXrpc(
+ agent,
+ 'community.blacksky.feed.getCommunityTimeline',
+ {params},
+ )
+ if (!res.ok) {
+ throw new Error(`getCommunityTimeline failed: ${res.status}`)
+ }
+ return (await res.json()) as CommunityFeedPage
+ },
+ initialPageParam: undefined,
+ getNextPageParam: lastPage => lastPage.cursor,
+ enabled,
+ })
+}
+
+const COMMUNITY_POST_RQKEY_ROOT = 'community-post'
+export const COMMUNITY_POST_RQKEY = (uri: string) => [
+ COMMUNITY_POST_RQKEY_ROOT,
+ uri,
+]
+
+export function useCommunityPostQuery(uri: string | undefined) {
+ const agent = useAgent()
+ return useQuery({
+ queryKey: COMMUNITY_POST_RQKEY(uri || ''),
+ async queryFn() {
+ const res = await communityXrpc(
+ agent,
+ 'community.blacksky.feed.getCommunityPost',
+ {params: {uri: uri || ''}},
+ )
+ if (!res.ok) {
+ throw new Error(`getCommunityPost failed: ${res.status}`)
+ }
+ const data = (await res.json()) as {post: AppBskyFeedDefs.PostView}
+ return data.post
+ },
+ enabled: !!uri,
+ })
+}
+
+export interface HydratedCommunityPost {
+ post: AppBskyFeedDefs.PostView
+ record: AppBskyFeedPost.Record
+ moderation: ModerationDecision
+}
+
+/**
+ * Takes pre-hydrated feed items from the server and adds moderation decisions.
+ * The server now returns properly hydrated PostViews with author info and counts.
+ */
+export function useCommunityFeedHydrated(
+ feedItems: AppBskyFeedDefs.FeedViewPost[],
+): HydratedCommunityPost[] {
+ const moderationOpts = useModerationOpts()
+
+ return useMemo(() => {
+ if (!moderationOpts) return []
+
+ return feedItems
+ .filter(item => item?.post) // Filter out any undefined items
+ .map(item => {
+ const postView = item.post
+ const record = postView.record as AppBskyFeedPost.Record
+ const moderation = moderatePost(postView, moderationOpts)
+ return {post: postView, record, moderation}
+ })
+ }, [feedItems, moderationOpts])
+}
+
+/**
+ * Generator function to find all posts in the community feed cache.
+ * Used by the post shadow system to update cached posts after mutations.
+ */
+export function* findAllPostsInQueryData(
+ queryClient: QueryClient,
+ uri: string,
+): Generator {
+ const atUri = new AtUri(uri)
+
+ // Search both actor feeds and timeline
+ const queryDatas = [
+ ...queryClient.getQueriesData>({
+ queryKey: [RQKEY_ROOT],
+ }),
+ ...queryClient.getQueriesData>({
+ queryKey: [TIMELINE_RQKEY_ROOT],
+ }),
+ ]
+
+ for (const [_queryKey, queryData] of queryDatas) {
+ if (!queryData?.pages) {
+ continue
+ }
+ for (const page of queryData.pages) {
+ if (!page.feed) {
+ continue
+ }
+ for (const item of page.feed) {
+ if (!item?.post) {
+ continue
+ }
+ if (didOrHandleUriMatches(atUri, item.post)) {
+ yield item.post
+ }
+
+ // Check for quoted posts in embeds
+ const quotedPost = getEmbeddedPost(item.post.embed)
+ if (quotedPost && didOrHandleUriMatches(atUri, quotedPost)) {
+ yield embedViewRecordToPostView(quotedPost)
+ }
+ }
+ }
+ }
+}
diff --git a/src/state/queries/feed.ts b/src/state/queries/feed.ts
index ac6e4bf7f..c55fd7d0e 100644
--- a/src/state/queries/feed.ts
+++ b/src/state/queries/feed.ts
@@ -549,6 +549,32 @@ const createPinnedFeedInfosQueryKey = (
},
)
+const COMMUNITY_FEED_STUB: SavedFeedSourceInfo = {
+ type: 'feed',
+ displayName: 'Community',
+ uri: 'community',
+ feedDescriptor: 'community',
+ route: {
+ href: '/',
+ name: 'Home',
+ params: {},
+ },
+ cid: '',
+ avatar: '',
+ description: new RichText({text: ''}),
+ creatorDid: '',
+ creatorHandle: '',
+ likeCount: 0,
+ likeUri: '',
+ savedFeed: {
+ id: 'community',
+ type: 'feed',
+ value: 'community',
+ pinned: true,
+ },
+ contentMode: undefined,
+}
+
export function usePinnedFeedsInfos() {
const {hasSession} = useSession()
const agent = useAgent()
@@ -635,6 +661,9 @@ export function usePinnedFeedsInfos() {
})
}
}
+ // Inject Community feed after the first item (Following)
+ const insertIndex = Math.min(1, result.length)
+ result.splice(insertIndex, 0, COMMUNITY_FEED_STUB)
return result
},
})
diff --git a/src/state/queries/post-feed.ts b/src/state/queries/post-feed.ts
index 959ed81c2..b0c226b23 100644
--- a/src/state/queries/post-feed.ts
+++ b/src/state/queries/post-feed.ts
@@ -58,6 +58,7 @@ type PostsUriList = string
export type FeedDescriptor =
| 'following'
+ | 'community'
| `author|${ActorDid}|${AuthorFilter}`
| `feedgen|${FeedUri}`
| `likes|${ActorDid}`
diff --git a/src/state/queries/post.ts b/src/state/queries/post.ts
index 79df51d1b..d12f33daa 100644
--- a/src/state/queries/post.ts
+++ b/src/state/queries/post.ts
@@ -7,6 +7,7 @@ import {
useQueryClient,
} from '@tanstack/react-query'
+import {communityXrpc} from '#/lib/api/community'
import {useToggleMutationQueue} from '#/lib/hooks/useToggleMutationQueue'
import {updatePostShadow} from '#/state/cache/post-shadow'
import {type Shadow} from '#/state/cache/types'
@@ -16,6 +17,12 @@ import {useAnalytics} from '#/analytics'
import {type Metrics, toClout} from '#/analytics/metrics'
import {useIsThreadMuted, useSetThreadMute} from '../cache/thread-mutes'
import {findProfileQueryData} from './profile'
+import {
+ fetchQueryWithFallback,
+ useMutation,
+ useQuery,
+ useQueryClient,
+} from './useQueryWithFallback'
const RQKEY_ROOT = 'post'
export const RQKEY = (postUri: string) => [RQKEY_ROOT, postUri]
@@ -348,12 +355,34 @@ function usePostUnrepostMutation(
})
}
+const COMMUNITY_POST_COLLECTION = 'community.blacksky.feed.post'
+
export function usePostDeleteMutation() {
const queryClient = useQueryClient()
const agent = useAgent()
return useMutation({
mutationFn: async ({uri}) => {
- await agent.deletePost(uri)
+ const parsedUri = new AtUri(uri)
+ if (parsedUri.collection === COMMUNITY_POST_COLLECTION) {
+ // Delete from community DB via appview
+ const res = await communityXrpc(
+ agent,
+ 'community.blacksky.feed.deletePost',
+ {body: {uri}},
+ )
+ if (!res.ok) {
+ const err = await res.json().catch(() => ({}))
+ throw new Error(err.message || `deletePost failed: ${res.status}`)
+ }
+ // Also delete the stub record from PDS
+ await agent.com.atproto.repo.deleteRecord({
+ repo: parsedUri.hostname,
+ collection: COMMUNITY_POST_COLLECTION,
+ rkey: parsedUri.rkey,
+ })
+ } else {
+ await agent.deletePost(uri)
+ }
},
onSuccess(_, variables) {
updatePostShadow(queryClient, variables.uri, {isDeleted: true})
diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts
index 9399abafb..2f5a70ec6 100644
--- a/src/state/queries/profile.ts
+++ b/src/state/queries/profile.ts
@@ -48,6 +48,15 @@ import {
import {RQKEY_ROOT as RQKEY_LIST_CONVOS} from './messages/list-conversations'
import {RQKEY as RQKEY_MY_BLOCKED} from './my-blocked-accounts'
import {RQKEY as RQKEY_MY_MUTED} from './my-muted-accounts'
+import {
+ type InfiniteData,
+ keepPreviousData,
+ prefetchQueryWithFallback,
+ type QueryClient,
+ useMutation,
+ useQuery,
+ useQueryClient,
+} from './useQueryWithFallback'
export * from '#/state/queries/unstable-profile-cache'
/**
@@ -171,9 +180,11 @@ export function useBskyProfileQuery({did}: {did: string | undefined}) {
export function useProfilesQuery({
handles,
maintainData,
+ enabled,
}: {
handles: string[]
maintainData?: boolean
+ enabled?: boolean
}) {
const agent = useAgent()
return useQuery({
@@ -184,6 +195,7 @@ export function useProfilesQuery({
return res.data
},
placeholderData: maintainData ? keepPreviousData : undefined,
+ enabled,
})
}
diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx
index c6c6215ba..6970bf0d0 100644
--- a/src/view/com/composer/Composer.tsx
+++ b/src/view/com/composer/Composer.tsx
@@ -125,6 +125,7 @@ import {atoms as a, native, useBreakpoints, useTheme, web} from '#/alf'
import {Admonition} from '#/components/Admonition'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import * as EmojiPicker from '#/components/EmojiPicker'
+import * as Toggle from '#/components/forms/Toggle'
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfoIcon} from '#/components/icons/CircleInfo'
import {EmojiArc_Stroke2_Corner0_Rounded as EmojiSmileIcon} from '#/components/icons/Emoji'
import {PlusLarge_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/Plus'
@@ -1142,8 +1143,19 @@ export const ComposePost = ({
{
- const {host: name, rkey} = new AtUri(postUri)
- navigation.navigate('PostThread', {name, rkey})
+ const urip = new AtUri(postUri)
+ const params: {
+ name: string
+ rkey: string
+ collection?: string
+ } = {
+ name: urip.host,
+ rkey: urip.rkey,
+ }
+ if (urip.collection !== 'app.bsky.feed.post') {
+ params.collection = urip.collection
+ }
+ navigation.navigate('PostThread', params)
}}>
View
@@ -1949,6 +1961,7 @@ function ComposerPills({
bottomBarAnimatedStyle: StyleProp
}) {
const t = useTheme()
+ const {_} = useLingui()
const media = post.embed.media
const hasMedia =
media?.type === 'images' ||
@@ -1958,6 +1971,7 @@ function ComposerPills({
const hasLink = !!post.embed.link
// Don't render anything if no pills are going to be displayed
+ // Always show for non-replies (Blacksky Only toggle is available)
if (isReply && !hasMedia && !hasLink) {
return null
}
@@ -1987,6 +2001,21 @@ function ComposerPills({
style={bottomBarAnimatedStyle}
/>
)}
+ {isReply ? null : (
+ {
+ dispatch({type: 'toggle_blacksky_only'})
+ }}
+ style={[a.flex_row, a.align_center, a.gap_xs]}>
+
+ Blacksky Only
+
+
+
+ )}
{hasMedia || hasLink ? (
(null)
+ const {openComposer} = useOpenComposer()
+
+ const onPressCompose = useCallback(() => {
+ openComposer({logContext: 'Fab'})
+ }, [openComposer])
+
+ const {
+ data,
+ isLoading,
+ isError,
+ hasNextPage,
+ fetchNextPage,
+ isFetchingNextPage,
+ refetch,
+ } = useCommunityTimelineQuery(isPageFocused)
+
+ const feedItems = useMemo(
+ () => data?.pages.flatMap(page => page.feed ?? []) ?? [],
+ [data],
+ )
+
+ const hydratedPosts = useCommunityFeedHydrated(feedItems)
+
+ const _onScrollToTop = useCallback(() => {
+ scrollElRef.current?.scrollToOffset({
+ animated: IS_NATIVE,
+ offset: -headerOffset,
+ })
+ refetch()
+ }, [scrollElRef, headerOffset, refetch])
+
+ const renderItem = useCallback(
+ ({item, index}: ListRenderItemInfo) => {
+ return (
+
+ )
+ },
+ [],
+ )
+
+ const keyExtractor = useCallback(
+ (item: HydratedCommunityPost) => item.post.uri,
+ [],
+ )
+
+ const onEndReached = useCallback(() => {
+ if (hasNextPage && !isFetchingNextPage) {
+ fetchNextPage()
+ }
+ }, [hasNextPage, isFetchingNextPage, fetchNextPage])
+
+ const renderEmpty = useCallback(() => {
+ if (isLoading) {
+ return (
+
+
+
+ )
+ }
+ if (isError) {
+ return (
+
+
+ Failed to load community posts
+
+
+ )
+ }
+ return (
+
+
+ No community posts yet
+
+
+ )
+ }, [isLoading, isError, t])
+
+ const renderFooter = useCallback(() => {
+ if (isFetchingNextPage) {
+ return (
+
+
+
+ )
+ }
+ if (!hasNextPage && hydratedPosts.length > 0) {
+ return (
+
+
+ End of feed
+
+
+ )
+ }
+ return null
+ }, [isFetchingNextPage, hasNextPage, hydratedPosts.length, t])
+
+ return (
+
+
+
+
+ {hasSession && (
+ }
+ accessibilityRole="button"
+ accessibilityLabel={_(msg`New post`)}
+ accessibilityHint=""
+ />
+ )}
+
+ )
+}
diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx
index c95222455..0e701312e 100644
--- a/src/view/com/post/Post.tsx
+++ b/src/view/com/post/Post.tsx
@@ -123,7 +123,10 @@ function PostInner({
() => countLines(richText?.text) >= MAX_POST_LINES,
)
const itemUrip = new AtUri(post.uri)
- const itemHref = makeProfileLink(post.author, 'post', itemUrip.rkey)
+ const isCommunityPost = itemUrip.collection === 'community.blacksky.feed.post'
+ const itemHref = isCommunityPost
+ ? `${makeProfileLink(post.author, 'post', itemUrip.rkey)}?collection=${itemUrip.collection}`
+ : makeProfileLink(post.author, 'post', itemUrip.rkey)
let replyAuthorDid = ''
if (record.reply) {
const urip = new AtUri(record.reply.parent?.uri || record.reply.root.uri)
diff --git a/src/view/com/posts/PostFeedItem.tsx b/src/view/com/posts/PostFeedItem.tsx
index c0ff26206..6fa693578 100644
--- a/src/view/com/posts/PostFeedItem.tsx
+++ b/src/view/com/posts/PostFeedItem.tsx
@@ -174,7 +174,12 @@ let FeedItemInner = ({
const [href] = useMemo(() => {
const urip = new AtUri(post.uri)
- return [makeProfileLink(post.author, 'post', urip.rkey), urip.rkey]
+ const link = makeProfileLink(post.author, 'post', urip.rkey)
+ const isCommunity = urip.collection === 'community.blacksky.feed.post'
+ return [
+ isCommunity ? `${link}?collection=${urip.collection}` : link,
+ urip.rkey,
+ ]
}, [post.uri, post.author])
const {sendInteraction, feedSourceInfo, feedDescriptor} =
useFeedFeedbackContext()
diff --git a/src/view/com/posts/ViewFullThread.tsx b/src/view/com/posts/ViewFullThread.tsx
index 2a0eb5135..6fa239520 100644
--- a/src/view/com/posts/ViewFullThread.tsx
+++ b/src/view/com/posts/ViewFullThread.tsx
@@ -14,7 +14,13 @@ export function ViewFullThread({uri}: {uri: string}) {
const t = useTheme()
const itemHref = useMemo(() => {
const urip = new AtUri(uri)
- return makeProfileLink({did: urip.hostname, handle: ''}, 'post', urip.rkey)
+ const link = makeProfileLink(
+ {did: urip.hostname, handle: ''},
+ 'post',
+ urip.rkey,
+ )
+ const isCommunity = urip.collection === 'community.blacksky.feed.post'
+ return isCommunity ? `${link}?collection=${urip.collection}` : link
}, [uri])
const {t: l} = useLingui()
diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx
index 50c10b819..94193cdae 100644
--- a/src/view/screens/Home.tsx
+++ b/src/view/screens/Home.tsx
@@ -23,6 +23,7 @@ import {type UsePreferencesQueryResponse} from '#/state/queries/preferences/type
import {useSession} from '#/state/session'
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed'
+import {CommunityFeedPage} from '#/view/com/feeds/CommunityFeedPage'
import {FeedPage} from '#/view/com/feeds/FeedPage'
import {HomeHeader} from '#/view/com/home/HomeHeader'
import {
@@ -307,6 +308,14 @@ function HomeScreenReady({
/>
)
}
+ if (feed === 'community') {
+ return (
+
+ )
+ }
const savedFeedConfig = feedInfo.savedFeed
return (
export function PostThreadScreen({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)
return (
diff --git a/src/view/screens/Profile.tsx b/src/view/screens/Profile.tsx
index 703e2c5c6..517cce1d1 100644
--- a/src/view/screens/Profile.tsx
+++ b/src/view/screens/Profile.tsx
@@ -42,6 +42,7 @@ import {FAB} from '#/view/com/util/fab/FAB'
import {type ListRef} from '#/view/com/util/List'
import {ProfileStatusError} from '#/screens/Profile/components/ProfileStatusError'
import {ProfileHeader, ProfileHeaderLoading} from '#/screens/Profile/Header'
+import {CommunityFeedSection} from '#/screens/Profile/Sections/CommunityFeed'
import {ProfileFeedSection} from '#/screens/Profile/Sections/Feed'
import {ProfileLabelsSection} from '#/screens/Profile/Sections/Labels'
import {atoms as a, useTheme} from '#/alf'
@@ -217,6 +218,7 @@ function ProfileScreenLoaded({
const [scrollViewTag, setScrollViewTag] = useState(null)
const postsSectionRef = useRef(null)
+ const communitySectionRef = useRef(null)
const repliesSectionRef = useRef(null)
const mediaSectionRef = useRef(null)
const videosSectionRef = useRef(null)
@@ -241,6 +243,7 @@ function ProfileScreenLoaded({
const hasLabeler = !!profile.associated?.labeler
const showFiltersTab = hasLabeler
const showPostsTab = true
+ const showCommunityTab = hasSession
const showRepliesTab = hasSession
const showMediaTab = !hasLabeler
const showVideosTab = !hasLabeler
@@ -257,6 +260,7 @@ function ProfileScreenLoaded({
showFiltersTab ? _(msg`Labels`) : undefined,
showListsTab && hasLabeler ? _(msg`Lists`) : undefined,
showPostsTab ? _(msg`Posts`) : undefined,
+ showCommunityTab ? _(msg`Community`) : undefined,
showRepliesTab ? _(msg`Replies`) : undefined,
showMediaTab ? _(msg`Media`) : undefined,
showVideosTab ? _(msg`Videos`) : undefined,
@@ -269,6 +273,7 @@ function ProfileScreenLoaded({
let nextIndex = 0
let filtersIndex: number | null = null
let postsIndex: number | null = null
+ let communityIndex: number | null = null
let repliesIndex: number | null = null
let mediaIndex: number | null = null
let videosIndex: number | null = null
@@ -282,6 +287,9 @@ function ProfileScreenLoaded({
if (showPostsTab) {
postsIndex = nextIndex++
}
+ if (showCommunityTab) {
+ communityIndex = nextIndex++
+ }
if (showRepliesTab) {
repliesIndex = nextIndex++
}
@@ -310,6 +318,8 @@ function ProfileScreenLoaded({
labelsSectionRef.current?.scrollToTop()
} else if (index === postsIndex) {
postsSectionRef.current?.scrollToTop()
+ } else if (index === communityIndex) {
+ communitySectionRef.current?.scrollToTop()
} else if (index === repliesIndex) {
repliesSectionRef.current?.scrollToTop()
} else if (index === mediaIndex) {
@@ -329,6 +339,7 @@ function ProfileScreenLoaded({
[
filtersIndex,
postsIndex,
+ communityIndex,
repliesIndex,
mediaIndex,
videosIndex,
@@ -468,6 +479,18 @@ function ProfileScreenLoaded({
/>
)
: null}
+ {showCommunityTab
+ ? ({headerHeight, isFocused, scrollElRef}) => (
+
+ )
+ : null}
{showRepliesTab
? ({headerHeight, isFocused, scrollElRef}) => (