Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 77 lines 2.2 kB view raw
1import { 2 type AppBskyActorDefs, 3 type AppBskyUnspeccedGetSuggestedUsersForSeeMore, 4} from '@atproto/api' 5import {type QueryClient, useQuery} from '@tanstack/react-query' 6 7import { 8 aggregateUserInterests, 9 createBskyTopicsHeader, 10} from '#/lib/api/feed/utils' 11import {getContentLanguages} from '#/state/preferences/languages' 12import {STALE} from '#/state/queries' 13import {usePreferencesQuery} from '#/state/queries/preferences' 14import {useAgent} from '#/state/session' 15 16export type QueryProps = { 17 category?: string | null 18 limit?: number 19} 20 21export const getSuggestedUsersForSeeMoreQueryKeyRoot = 22 'unspecced-suggested-users-for-explore' 23export const createGetSuggestedUsersForSeeMoreQueryKey = ( 24 props: QueryProps, 25) => [getSuggestedUsersForSeeMoreQueryKeyRoot, props.category, props.limit] 26 27export function useGetSuggestedUsersForSeeMoreQuery(props: QueryProps = {}) { 28 const agent = useAgent() 29 const {data: preferences} = usePreferencesQuery() 30 31 return useQuery({ 32 staleTime: STALE.MINUTES.THREE, 33 queryKey: createGetSuggestedUsersForSeeMoreQueryKey(props), 34 queryFn: async () => { 35 const contentLangs = getContentLanguages().join(',') 36 const userInterests = aggregateUserInterests(preferences) 37 38 const {data} = await agent.app.bsky.unspecced.getSuggestedUsersForSeeMore( 39 { 40 category: props.category ?? undefined, 41 limit: props.limit || 50, 42 }, 43 { 44 headers: { 45 ...createBskyTopicsHeader(userInterests), 46 'Accept-Language': contentLangs, 47 }, 48 }, 49 ) 50 51 return {...data, recId: data.recIdStr} 52 }, 53 }) 54} 55 56export function* findAllProfilesInQueryData( 57 queryClient: QueryClient, 58 did: string, 59): Generator<AppBskyActorDefs.ProfileView, void> { 60 const responses = 61 queryClient.getQueriesData<AppBskyUnspeccedGetSuggestedUsersForSeeMore.OutputSchema>( 62 { 63 queryKey: [getSuggestedUsersForSeeMoreQueryKeyRoot], 64 }, 65 ) 66 for (const [_key, response] of responses) { 67 if (!response) { 68 continue 69 } 70 71 for (const actor of response.actors) { 72 if (actor.did === did) { 73 yield actor 74 } 75 } 76 } 77}