Replace getAgent() with reading agent (#4243)

* Replace getAgent() with agent

* Replace {agent} with agent
This commit is contained in:
dan
2024-05-28 16:37:51 +01:00
committed by GitHub
parent 8a2f43c218
commit 9bd411c151
74 changed files with 400 additions and 438 deletions
+9 -9
View File
@@ -31,12 +31,12 @@ export function useLabelerInfoQuery({
did?: string
enabled?: boolean
}) {
const {getAgent} = useAgent()
const agent = useAgent()
return useQuery({
enabled: !!did && enabled !== false,
queryKey: labelerInfoQueryKey(did as string),
queryFn: async () => {
const res = await getAgent().app.bsky.labeler.getServices({
const res = await agent.app.bsky.labeler.getServices({
dids: [did as string],
detailed: true,
})
@@ -46,26 +46,26 @@ export function useLabelerInfoQuery({
}
export function useLabelersInfoQuery({dids}: {dids: string[]}) {
const {getAgent} = useAgent()
const agent = useAgent()
return useQuery({
enabled: !!dids.length,
queryKey: labelersInfoQueryKey(dids),
queryFn: async () => {
const res = await getAgent().app.bsky.labeler.getServices({dids})
const res = await agent.app.bsky.labeler.getServices({dids})
return res.data.views as AppBskyLabelerDefs.LabelerView[]
},
})
}
export function useLabelersDetailedInfoQuery({dids}: {dids: string[]}) {
const {getAgent} = useAgent()
const agent = useAgent()
return useQuery({
enabled: !!dids.length,
queryKey: labelersDetailedInfoQueryKey(dids),
gcTime: 1000 * 60 * 60 * 6, // 6 hours
staleTime: STALE.MINUTES.ONE,
queryFn: async () => {
const res = await getAgent().app.bsky.labeler.getServices({
const res = await agent.app.bsky.labeler.getServices({
dids,
detailed: true,
})
@@ -76,7 +76,7 @@ export function useLabelersDetailedInfoQuery({dids}: {dids: string[]}) {
export function useLabelerSubscriptionMutation() {
const queryClient = useQueryClient()
const {getAgent} = useAgent()
const agent = useAgent()
return useMutation({
async mutationFn({did, subscribe}: {did: string; subscribe: boolean}) {
@@ -87,9 +87,9 @@ export function useLabelerSubscriptionMutation() {
}).parse({did, subscribe})
if (subscribe) {
await getAgent().addLabeler(did)
await agent.addLabeler(did)
} else {
await getAgent().removeLabeler(did)
await agent.removeLabeler(did)
}
},
onSuccess() {