diff options
author | Eric Bailey <git@esb.lol> | 2024-08-02 13:05:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-02 13:05:33 -0500 |
commit | c3d8beee6dc141ced2c41795f90b3309a2bc75a2 (patch) | |
tree | e2aa55a6e79616ec989b7426e2c46b4cd56b91e2 /src/state/queries/profile-feedgens.ts | |
parent | 293ac6fab21f26baa8347c998f3a50224112c7c5 (diff) | |
download | voidsky-c3d8beee6dc141ced2c41795f90b3309a2bc75a2.tar.zst |
Respect labels on feeds and lists (#4818)
* Prep * Pass in optional moderation to FeedCard * Compute moderation decision, filter contentList contexts, pass into card * Let's go a different route * Filter from within search queries * Use same search query for starter packs * Filter lists from profile tabs * Cleanup * Filter from profile feeds * Moderate post embeds * Memoize * Use ScreenHider on lists * Hide both list types * Fix crash on iOS in screen hider, fix lineheight * Memoize renderItem * Reuse objects to prevent re-renders
Diffstat (limited to 'src/state/queries/profile-feedgens.ts')
-rw-r--r-- | src/state/queries/profile-feedgens.ts | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/state/queries/profile-feedgens.ts b/src/state/queries/profile-feedgens.ts index 8ad12ab61..b50a2a289 100644 --- a/src/state/queries/profile-feedgens.ts +++ b/src/state/queries/profile-feedgens.ts @@ -1,7 +1,8 @@ -import {AppBskyFeedGetActorFeeds} from '@atproto/api' +import {AppBskyFeedGetActorFeeds, moderateFeedGenerator} from '@atproto/api' import {InfiniteData, QueryKey, useInfiniteQuery} from '@tanstack/react-query' import {useAgent} from '#/state/session' +import {useModerationOpts} from '../preferences/moderation-opts' const PAGE_SIZE = 50 type RQPageParam = string | undefined @@ -14,7 +15,8 @@ export function useProfileFeedgensQuery( did: string, opts?: {enabled?: boolean}, ) { - const enabled = opts?.enabled !== false + const moderationOpts = useModerationOpts() + const enabled = opts?.enabled !== false && Boolean(moderationOpts) const agent = useAgent() return useInfiniteQuery< AppBskyFeedGetActorFeeds.OutputSchema, @@ -38,5 +40,21 @@ export function useProfileFeedgensQuery( initialPageParam: undefined, getNextPageParam: lastPage => lastPage.cursor, enabled, + select(data) { + return { + ...data, + pages: data.pages.map(page => { + return { + ...page, + feeds: page.feeds + // filter by labels + .filter(list => { + const decision = moderateFeedGenerator(list, moderationOpts!) + return !decision.ui('contentList').filter + }), + } + }), + } + }, }) } |