diff options
author | dan <dan.abramov@gmail.com> | 2023-11-13 18:35:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-13 10:35:15 -0800 |
commit | e1938931e028f4486cce8cd9da39ffd940c10ec2 (patch) | |
tree | d7d22d93a95503350ab4d2d0ace409cd873815cb /src/state/queries/resolve-uri.ts | |
parent | c3edde8ac6f9c65eac1004cd8e2fc14b0493cba8 (diff) | |
download | voidsky-e1938931e028f4486cce8cd9da39ffd940c10ec2.tar.zst |
Refactor profile screen to use new pager and react-query (#1870)
* Profile tabs WIP * Refactor the profile screen to use react-query (WIP) * Add the profile shadow and get follow, mute, and block working * Cleanup --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Diffstat (limited to 'src/state/queries/resolve-uri.ts')
-rw-r--r-- | src/state/queries/resolve-uri.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/state/queries/resolve-uri.ts b/src/state/queries/resolve-uri.ts index 26e0a475b..83bccdce7 100644 --- a/src/state/queries/resolve-uri.ts +++ b/src/state/queries/resolve-uri.ts @@ -4,17 +4,22 @@ import {useSession} from '../session' export const RQKEY = (uri: string) => ['resolved-uri', uri] -export function useResolveUriQuery(uri: string) { +export function useResolveUriQuery(uri: string | undefined) { const {agent} = useSession() - return useQuery<string | undefined, Error>({ - queryKey: RQKEY(uri), + return useQuery<{uri: string; did: string}, Error>({ + queryKey: RQKEY(uri || ''), async queryFn() { - const urip = new AtUri(uri) + const urip = new AtUri(uri || '') if (!urip.host.startsWith('did:')) { const res = await agent.resolveHandle({handle: urip.host}) urip.host = res.data.did } - return urip.toString() + return {did: urip.host, uri: urip.toString()} }, + enabled: !!uri, }) } + +export function useResolveDidQuery(didOrHandle: string | undefined) { + return useResolveUriQuery(didOrHandle ? `at://${didOrHandle}/` : undefined) +} |