De-closure list
This commit is contained in:
+19
-11
@@ -6,7 +6,12 @@ import {
|
|||||||
BskyAgent,
|
BskyAgent,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {Image as RNImage} from 'react-native-image-crop-picker'
|
import {Image as RNImage} from 'react-native-image-crop-picker'
|
||||||
import {useQuery, useMutation, useQueryClient} from '@tanstack/react-query'
|
import {
|
||||||
|
useQuery,
|
||||||
|
useMutation,
|
||||||
|
useQueryClient,
|
||||||
|
QueryFunctionContext,
|
||||||
|
} from '@tanstack/react-query'
|
||||||
import chunk from 'lodash.chunk'
|
import chunk from 'lodash.chunk'
|
||||||
import {useSession, getAgent} from '../session'
|
import {useSession, getAgent} from '../session'
|
||||||
import {invalidate as invalidateMyLists} from './my-lists'
|
import {invalidate as invalidateMyLists} from './my-lists'
|
||||||
@@ -21,20 +26,23 @@ export function useListQuery(uri?: string) {
|
|||||||
return useQuery<AppBskyGraphDefs.ListView, Error>({
|
return useQuery<AppBskyGraphDefs.ListView, Error>({
|
||||||
staleTime: STALE.MINUTES.ONE,
|
staleTime: STALE.MINUTES.ONE,
|
||||||
queryKey: RQKEY(uri || ''),
|
queryKey: RQKEY(uri || ''),
|
||||||
async queryFn() {
|
queryFn: listQueryFn,
|
||||||
if (!uri) {
|
|
||||||
throw new Error('URI not provided')
|
|
||||||
}
|
|
||||||
const res = await getAgent().app.bsky.graph.getList({
|
|
||||||
list: uri,
|
|
||||||
limit: 1,
|
|
||||||
})
|
|
||||||
return res.data.list
|
|
||||||
},
|
|
||||||
enabled: !!uri,
|
enabled: !!uri,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function listQueryFn({queryKey}: QueryFunctionContext) {
|
||||||
|
const [_, uri] = queryKey as ReturnType<typeof RQKEY>
|
||||||
|
if (!uri) {
|
||||||
|
throw new Error('URI not provided')
|
||||||
|
}
|
||||||
|
const res = await getAgent().app.bsky.graph.getList({
|
||||||
|
list: uri,
|
||||||
|
limit: 1,
|
||||||
|
})
|
||||||
|
return res.data.list
|
||||||
|
}
|
||||||
|
|
||||||
export interface ListCreateMutateParams {
|
export interface ListCreateMutateParams {
|
||||||
purpose: string
|
purpose: string
|
||||||
name: string
|
name: string
|
||||||
|
|||||||
Reference in New Issue
Block a user