diff --git a/src/features/followingV2/home/Home.tsx b/src/features/followingV2/home/Home.tsx
index 6c6c610d9..22e1d0365 100644
--- a/src/features/followingV2/home/Home.tsx
+++ b/src/features/followingV2/home/Home.tsx
@@ -31,6 +31,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 {HomeHeader} from '#/view/com/home/HomeHeader'
import {
Pager,
@@ -316,6 +317,14 @@ function HomeScreenReady({
/>
)
}
+ if (feed === 'community') {
+ return (
+
+ )
+ }
const savedFeedConfig = feedInfo.savedFeed
return (
{
+ expect(CustomFeedAPI).toBe(LegacyCustomFeedAPI)
+})
diff --git a/src/features/followingV2/home/api/custom.ts b/src/features/followingV2/home/api/custom.ts
index 3b566dfaf..57c4078e6 100644
--- a/src/features/followingV2/home/api/custom.ts
+++ b/src/features/followingV2/home/api/custom.ts
@@ -1,206 +1,6 @@
-import {
- type Client,
- type XrpcRequestParams,
- XrpcResponseError,
-} from '@atproto/lex'
-
-import {
- createBskyFeedHeaders,
- createBskyTopicsHeader,
- isBlueskyOwnedFeed,
-} from '#/lib/api/feed/utils'
-import {PUBLIC_APPVIEW} from '#/lib/constants'
-import {createLexClient} from '#/lib/lexClient'
-import {
- getAppLanguageAsContentLanguage,
- getContentLanguages,
-} from '#/state/preferences/languages'
-import {app} from '#/lexicons'
-import {type FeedAPI, type FeedAPIResponse} from './types'
-
-type GetCustomFeedParams = XrpcRequestParams
-
-export class CustomFeedAPI implements FeedAPI {
- client: Client
- params: GetCustomFeedParams
- userInterests?: string
-
- constructor({
- client,
- feedParams,
- userInterests,
- }: {
- client: Client
- feedParams: GetCustomFeedParams
- userInterests?: string
- }) {
- this.client = client
- this.params = feedParams
- this.userInterests = userInterests
- }
-
- async peekLatest(): Promise {
- const contentLangs = getContentLanguages().join(',')
- const data = await this.client.call(
- app.bsky.feed.getFeed,
- {
- ...this.params,
- limit: 1,
- },
- {
- headers: {
- ...createBskyFeedHeaders(this.params.feed),
- 'Accept-Language': contentLangs,
- },
- },
- )
- return data.feed[0]
- }
-
- async fetch({
- cursor,
- limit,
- signal,
- }: {
- cursor: string | undefined
- limit: number
- signal?: AbortSignal
- }): Promise {
- const contentLangs = getContentLanguages().join(',')
- const isBlueskyOwned = isBlueskyOwnedFeed(this.params.feed)
-
- /*
- * The authed branch rejects on failure, so the error propagates to the
- * query and drives the feed error UI (feedgen offline, misconfigured, rate
- * limited). Only the logged-out branch can resolve without data, and it
- * signals that with a null body.
- */
- const data = this.client.did
- ? await this.client.call(
- app.bsky.feed.getFeed,
- {
- ...this.params,
- cursor,
- limit,
- },
- {
- signal,
- headers: {
- ...createBskyFeedHeaders(this.params.feed),
- ...(isBlueskyOwned
- ? createBskyTopicsHeader(this.userInterests)
- : {}),
- 'Accept-Language': contentLangs,
- },
- },
- )
- : await loggedOutFetch({...this.params, cursor, limit}, signal)
-
- if (!data) {
- return {
- feed: [],
- }
- }
-
- // NOTE
- // some custom feeds fail to enforce the pagination limit
- // so we manually truncate here
- // -prf
- const feed =
- data.feed.length > limit ? data.feed.slice(0, limit) : data.feed
- return {
- cursor: data.cursor,
- feed,
- }
- }
-}
-
-let loggedOutAppviewClient: Client | undefined
-
-/**
- * The unauthenticated {@link Client} for logged-out feed reads, pointed at the
- * direct appview ({@link PUBLIC_APPVIEW}, `api.bsky.app`).
- *
- * Deliberately NOT the public appview client (`public.api.bsky.app`): that host
- * fronts a cache which does not vary on `Accept-Language`, so it would answer a
- * language-filtered read from another language's cached body. The direct
- * appview respects the header (verified 2026-08-04), at the cost of not being
- * cached. See {@link loggedOutFetch}.
- *
- * A single module-level instance, because there is no session to scope it to.
- * Like the public chat client, it uses plain `fetch` rather than
- * `networkAwareFetch`, matching the ad-hoc fetch it replaces: this read has its
- * own failure handling and should not move the app-wide network signal.
- */
-function getLoggedOutAppviewClient(): Client {
- return (loggedOutAppviewClient ??= createLexClient(
- {service: PUBLIC_APPVIEW},
- {includeDeviceSessionHeaders: false},
- ))
-}
-
/*
- * HACK
- * We want feeds to give language-specific results immediately when a logged-out
- * user changes their language. That comes with two problems:
- * 1. not all languages have content, and
- * 2. our public caching layer does not bust against the `Accept-Language`
- * header.
- * -prf
- *
- * Problem 2 is why this uses its own client rather than the app's public
- * appview one: it talks to the direct appview, which honors the header, instead
- * of the cached `public.api.bsky.app`, which does not vary on it. That trades
- * CDN caching for language correctness on logged-out feed traffic.
- *
- * Problem 1 is host-independent, so it is still handled here: an empty
- * language-filtered feed is retried once with the language constraint removed.
- */
-async function loggedOutFetch(
- params: GetCustomFeedParams,
- signal?: AbortSignal,
-): Promise {
- const contentLangs = getAppLanguageAsContentLanguage()
-
- let data = await getFeedOrNull(params, contentLangs, signal)
- if (data?.feed?.length) {
- return data
- }
-
- // no data, try again with language headers removed
- data = await getFeedOrNull(params, '', signal)
- return data
-}
-
-/**
- * A logged-out `getFeed` read that resolves to null on a response error.
- *
- * The pre-client code only guarded `res.ok`, so a failed RESPONSE fell through
- * to the next attempt while a failed REQUEST rejected. Catching
- * `XrpcResponseError` preserves that split: every other lex error - the fetch
- * and validation ones - still propagates.
+ * Custom feeds use the same implementation as the legacy Home. It routes
+ * permissioned-space and community-gated feeds, which the standard feed route
+ * refuses.
*/
-async function getFeedOrNull(
- params: GetCustomFeedParams,
- contentLangs: string,
- signal?: AbortSignal,
-): Promise {
- try {
- return await getLoggedOutAppviewClient().call(
- app.bsky.feed.getFeed,
- params,
- {
- signal,
- headers: {
- ...createBskyFeedHeaders(params.feed),
- 'Accept-Language': contentLangs,
- },
- },
- )
- } catch (e) {
- if (e instanceof XrpcResponseError) {
- return null
- }
- throw e
- }
-}
+export {CustomFeedAPI} from '#/lib/api/feed/custom'
diff --git a/src/features/followingV2/home/api/home.test.ts b/src/features/followingV2/home/api/home.test.ts
index 6120cbbd7..a00b987ad 100644
--- a/src/features/followingV2/home/api/home.test.ts
+++ b/src/features/followingV2/home/api/home.test.ts
@@ -3,6 +3,13 @@ import {type Client} from '@atproto/lex'
import {app} from '#/lexicons'
import {FALLBACK_MARKER_POST, HomeFeedAPI} from './home'
+// The custom feed API first asks whether a feed is community-gated; Discover is not.
+jest.mock('#/lib/api/community-feed', () => ({
+ ...jest.requireActual(
+ '#/lib/api/community-feed',
+ ),
+ fetchCommunityFeedConfigStrict: jest.fn(() => Promise.resolve(null)),
+}))
jest.mock('#/state/preferences/languages', () => ({
getAppLanguageAsContentLanguage: () => '',
getContentLanguages: () => [],
diff --git a/src/features/followingV2/home/queries/postFeed.test.tsx b/src/features/followingV2/home/queries/postFeed.test.tsx
index 1015dee56..4560d28a8 100644
--- a/src/features/followingV2/home/queries/postFeed.test.tsx
+++ b/src/features/followingV2/home/queries/postFeed.test.tsx
@@ -72,6 +72,13 @@ import {
// The app-wide mock of `multiformats/cid` can't tell a CID from anything else.
jest.unmock('multiformats/cid')
+// The custom feed API first asks whether a feed is community-gated; these are not.
+jest.mock('#/lib/api/community-feed', () => ({
+ ...jest.requireActual(
+ '#/lib/api/community-feed',
+ ),
+ fetchCommunityFeedConfigStrict: jest.fn(() => Promise.resolve(null)),
+}))
jest.mock('#/state/preferences/languages', () => ({
getAppLanguageAsContentLanguage: () => '',
getContentLanguages: () => [],
diff --git a/src/features/followingV2/home/queries/savedFeedSamples.test.tsx b/src/features/followingV2/home/queries/savedFeedSamples.test.tsx
index 46cb0c14f..079331364 100644
--- a/src/features/followingV2/home/queries/savedFeedSamples.test.tsx
+++ b/src/features/followingV2/home/queries/savedFeedSamples.test.tsx
@@ -12,6 +12,13 @@ import {type app} from '#/lexicons'
import {type FeedPage} from './postFeed'
import {RQKEY, useSavedFeedSamples} from './savedFeedSamples'
+// The custom feed API first asks whether a feed is community-gated; these are not.
+jest.mock('#/lib/api/community-feed', () => ({
+ ...jest.requireActual(
+ '#/lib/api/community-feed',
+ ),
+ fetchCommunityFeedConfigStrict: jest.fn(() => Promise.resolve(null)),
+}))
jest.mock('#/state/preferences/languages', () => ({
getAppLanguageAsContentLanguage: () => '',
getContentLanguages: () => [],