Replace getPostThread in threadgate query

This commit is contained in:
Eric Bailey
2025-10-10 16:41:40 -05:00
parent c8ded6291f
commit 28a2365e0c
2 changed files with 11 additions and 28 deletions
+4 -25
View File
@@ -1,5 +1,5 @@
import {
AppBskyFeedDefs,
type AppBskyFeedDefs,
AppBskyFeedThreadgate,
AtUri,
type BskyAgent,
@@ -70,7 +70,7 @@ export function useThreadgateViewQuery({
postUri?: string
initialData?: AppBskyFeedDefs.ThreadgateView
} = {}) {
const agent = useAgent()
const getPost = useGetPost()
return useQuery({
enabled: !!postUri,
@@ -78,33 +78,12 @@ export function useThreadgateViewQuery({
placeholderData: initialData,
staleTime: STALE.MINUTES.ONE,
async queryFn() {
return getThreadgateView({
agent,
postUri: postUri!,
})
const post = await getPost({uri: postUri!})
return post.threadgate ?? null
},
})
}
export async function getThreadgateView({
agent,
postUri,
}: {
agent: BskyAgent
postUri: string
}) {
const {data} = await agent.app.bsky.feed.getPostThread({
uri: postUri!,
depth: 0,
})
if (AppBskyFeedDefs.isThreadViewPost(data.thread)) {
return data.thread.post.threadgate ?? null
}
return null
}
export async function getThreadgateRecord({
agent,
postUri,