mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

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

at rm-precision 58 lines 1.4 kB view raw
1import {AppBskyActorDefs, AppBskyGraphGetMutes} from '@atproto/api' 2import { 3 InfiniteData, 4 QueryClient, 5 QueryKey, 6 useInfiniteQuery, 7} from '@tanstack/react-query' 8 9import {useAgent} from '#/state/session' 10 11const RQKEY_ROOT = 'my-muted-accounts' 12export const RQKEY = () => [RQKEY_ROOT] 13type RQPageParam = string | undefined 14 15export function useMyMutedAccountsQuery() { 16 const agent = useAgent() 17 return useInfiniteQuery< 18 AppBskyGraphGetMutes.OutputSchema, 19 Error, 20 InfiniteData<AppBskyGraphGetMutes.OutputSchema>, 21 QueryKey, 22 RQPageParam 23 >({ 24 queryKey: RQKEY(), 25 async queryFn({pageParam}: {pageParam: RQPageParam}) { 26 const res = await agent.app.bsky.graph.getMutes({ 27 limit: 30, 28 cursor: pageParam, 29 }) 30 return res.data 31 }, 32 initialPageParam: undefined, 33 getNextPageParam: lastPage => lastPage.cursor, 34 }) 35} 36 37export function* findAllProfilesInQueryData( 38 queryClient: QueryClient, 39 did: string, 40): Generator<AppBskyActorDefs.ProfileView, void> { 41 const queryDatas = queryClient.getQueriesData< 42 InfiniteData<AppBskyGraphGetMutes.OutputSchema> 43 >({ 44 queryKey: [RQKEY_ROOT], 45 }) 46 for (const [_queryKey, queryData] of queryDatas) { 47 if (!queryData?.pages) { 48 continue 49 } 50 for (const page of queryData?.pages) { 51 for (const mute of page.mutes) { 52 if (mute.did === did) { 53 yield mute 54 } 55 } 56 } 57 } 58}