diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-11-13 17:30:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-13 17:30:56 -0800 |
commit | a81c4b68fa9ae87dea0b1dec76012ef7a69fca26 (patch) | |
tree | 95044e61cab77ab81bb107341ee2904f4170b622 /src/state/queries/my-muted-accounts.ts | |
parent | 0501c2be778b1a8517da6ea4111bcbd56dc056ed (diff) | |
download | voidsky-a81c4b68fa9ae87dea0b1dec76012ef7a69fca26.tar.zst |
Update Muted and Blocked accounts screens (react-query refactor) (#1892)
* Add my-blocked-accounts and my-muted-accounts queries * Update ProfileCard to use the profile shadow cache and useModerationOpts * Update blocked accounts and muted accounts screens
Diffstat (limited to 'src/state/queries/my-muted-accounts.ts')
-rw-r--r-- | src/state/queries/my-muted-accounts.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/state/queries/my-muted-accounts.ts b/src/state/queries/my-muted-accounts.ts new file mode 100644 index 000000000..109874673 --- /dev/null +++ b/src/state/queries/my-muted-accounts.ts @@ -0,0 +1,28 @@ +import {AppBskyGraphGetMutes} from '@atproto/api' +import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query' +import {useSession} from '../session' + +export const RQKEY = () => ['my-muted-accounts'] +type RQPageParam = string | undefined + +export function useMyMutedAccountsQuery() { + const {agent} = useSession() + return useInfiniteQuery< + AppBskyGraphGetMutes.OutputSchema, + Error, + InfiniteData<AppBskyGraphGetMutes.OutputSchema>, + QueryKey, + RQPageParam + >({ + queryKey: RQKEY(), + async queryFn({pageParam}: {pageParam: RQPageParam}) { + const res = await agent.app.bsky.graph.getMutes({ + limit: 30, + cursor: pageParam, + }) + return res.data + }, + initialPageParam: undefined, + getNextPageParam: lastPage => lastPage.cursor, + }) +} |