include 'for you' in see more suggested users

This commit is contained in:
vineyardbovines
2026-04-13 09:20:56 -04:00
parent 5d0b900719
commit e14dd07c7c
3 changed files with 105 additions and 24 deletions
@@ -15,21 +15,23 @@ import {useAgent} from '#/state/session'
export type QueryProps = {
limit?: number
enabled?: boolean
}
export const getSuggestedUsersForDiscoverQueryKeyRoot =
'unspecced-suggested-users-for-explore'
export const createGetSuggestedUsersForDiscoverQueryKey = (
props: QueryProps,
) => [getSuggestedUsersForDiscoverQueryKeyRoot, props.limit]
export const createGetSuggestedUsersForDiscoverQueryKey = (props: {
limit?: number
}) => [getSuggestedUsersForDiscoverQueryKeyRoot, props.limit]
export function useGetSuggestedUsersForDiscoverQuery(props: QueryProps = {}) {
const agent = useAgent()
const {data: preferences} = usePreferencesQuery()
return useQuery({
enabled: props.enabled ?? true,
staleTime: STALE.MINUTES.THREE,
queryKey: createGetSuggestedUsersForDiscoverQueryKey(props),
queryKey: createGetSuggestedUsersForDiscoverQueryKey({limit: props.limit}),
queryFn: async () => {
const contentLangs = getContentLanguages().join(',')
const userInterests = aggregateUserInterests(preferences)
@@ -73,3 +75,33 @@ export function* findAllProfilesInQueryData(
}
}
}
/**
* Collects every DID currently cached under any `getSuggestedUsersForDiscover`
* query. Used by the See More dialog's For You tab to filter out profiles the
* viewer has already been shown by the home-feed interstitial (the endpoint
* has no cursor/offset, so we dedup client-side).
*
* The query key root is shared with `getSuggestedUsersForSeeMore`, so we
* narrow by key length (Discover keys are `[root, limit]`, SeeMore keys are
* `[root, category, limit]`).
*/
export function getAllDidsInDiscoverCache(
queryClient: QueryClient,
): Set<string> {
const dids = new Set<string>()
const responses =
queryClient.getQueriesData<AppBskyUnspeccedGetSuggestedUsersForDiscover.OutputSchema>(
{
queryKey: [getSuggestedUsersForDiscoverQueryKeyRoot],
},
)
for (const [key, response] of responses) {
if (!response) continue
if (key.length !== 2) continue
for (const actor of response.actors) {
dids.add(actor.did)
}
}
return dids
}