diff options
author | Eric Bailey <git@esb.lol> | 2023-11-10 08:46:45 -0600 |
---|---|---|
committer | Eric Bailey <git@esb.lol> | 2023-11-10 08:46:45 -0600 |
commit | b0c9cce5c3ea9246fbc2f71ac64c10c5252ec9a4 (patch) | |
tree | 510b14357ceff341a79c8947b9ea9b7e1fe4464d /src/state/queries | |
parent | 742f53d1ecfc5060b7e6fc0cea0f8729d2e9b1b5 (diff) | |
download | voidsky-b0c9cce5c3ea9246fbc2f71ac64c10c5252ec9a4.tar.zst |
Follow conventions for query, use isDirty flag in session store to avoid unneccessary writes
Diffstat (limited to 'src/state/queries')
-rw-r--r-- | src/state/queries/index.ts | 5 | ||||
-rw-r--r-- | src/state/queries/profile.ts | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/state/queries/index.ts b/src/state/queries/index.ts new file mode 100644 index 000000000..ae3d1595c --- /dev/null +++ b/src/state/queries/index.ts @@ -0,0 +1,5 @@ +import {BskyAgent} from '@atproto/api' + +export const PUBLIC_BSKY_AGENT = new BskyAgent({ + service: 'https://api.bsky.app', +}) diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts new file mode 100644 index 000000000..c2cd19482 --- /dev/null +++ b/src/state/queries/profile.ts @@ -0,0 +1,13 @@ +import {useQuery} from '@tanstack/react-query' + +import {PUBLIC_BSKY_AGENT} from '#/state/queries' + +export function useProfileQuery({did}: {did: string}) { + return useQuery({ + queryKey: ['getProfile', did], + queryFn: async () => { + const res = await PUBLIC_BSKY_AGENT.getProfile({actor: did}) + return res.data + }, + }) +} |