Skip to content

Commit

Permalink
let usePostQuery take uris with DIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius authored and estrattonbailey committed May 30, 2024
1 parent d8458c0 commit 16b577c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/state/queries/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ export function usePostQuery(uri: string | undefined) {
return useQuery<AppBskyFeedDefs.PostView>({
queryKey: RQKEY(uri || ''),
async queryFn() {
const res = await agent.getPosts({uris: [uri!]})
const urip = new AtUri(uri!)

if (!urip.host.startsWith('did:')) {
const res = await agent.resolveHandle({
handle: urip.host,
})
urip.host = res.data.did
}

const res = await agent.getPosts({uris: [urip.toString()]})
if (res.success && res.data.posts[0]) {
return res.data.posts[0]
}
Expand Down Expand Up @@ -47,7 +56,7 @@ export function useGetPost() {
}

const res = await agent.getPosts({
uris: [urip.toString()!],
uris: [urip.toString()],
})

if (res.success && res.data.posts[0]) {
Expand Down

0 comments on commit 16b577c

Please sign in to comment.