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>
This commit is contained in:
dan 2023-11-13 18:35:15 +00:00 committed by GitHub
parent c3edde8ac6
commit e1938931e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 730 additions and 456 deletions

View file

@ -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)
}