De-closure my-follows
This commit is contained in:
@@ -31,9 +31,9 @@ const SANITY_PAGE_LIMIT = 1000
|
|||||||
const PAGE_SIZE = 100
|
const PAGE_SIZE = 100
|
||||||
// ...which comes 100,000k list members
|
// ...which comes 100,000k list members
|
||||||
|
|
||||||
export const RQKEY = (userDid: string | undefined) => [
|
export const RQKEY = (sessionDid: string | undefined) => [
|
||||||
'list-memberships',
|
'list-memberships',
|
||||||
userDid,
|
sessionDid,
|
||||||
]
|
]
|
||||||
|
|
||||||
export interface ListMembersip {
|
export interface ListMembersip {
|
||||||
@@ -57,15 +57,15 @@ export function useDangerousListMembershipsQuery() {
|
|||||||
async function dangerousListMembershipsQueryFn({
|
async function dangerousListMembershipsQueryFn({
|
||||||
queryKey,
|
queryKey,
|
||||||
}: QueryFunctionContext) {
|
}: QueryFunctionContext) {
|
||||||
const [_, userDid] = queryKey as ReturnType<typeof RQKEY>
|
const [_, sessionDid] = queryKey as ReturnType<typeof RQKEY>
|
||||||
if (!userDid) {
|
if (!sessionDid) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
let cursor
|
let cursor
|
||||||
let arr: ListMembersip[] = []
|
let arr: ListMembersip[] = []
|
||||||
for (let i = 0; i < SANITY_PAGE_LIMIT; i++) {
|
for (let i = 0; i < SANITY_PAGE_LIMIT; i++) {
|
||||||
const res = await getAgent().app.bsky.graph.listitem.list({
|
const res = await getAgent().app.bsky.graph.listitem.list({
|
||||||
repo: userDid,
|
repo: sessionDid,
|
||||||
limit: PAGE_SIZE,
|
limit: PAGE_SIZE,
|
||||||
cursor,
|
cursor,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {AppBskyActorDefs} from '@atproto/api'
|
import {AppBskyActorDefs} from '@atproto/api'
|
||||||
import {useQuery} from '@tanstack/react-query'
|
import {QueryFunctionContext, useQuery} from '@tanstack/react-query'
|
||||||
import {useSession, getAgent} from '../session'
|
import {useSession, getAgent} from '../session'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
|
|
||||||
@@ -8,38 +8,44 @@ const SANITY_PAGE_LIMIT = 1000
|
|||||||
const PAGE_SIZE = 100
|
const PAGE_SIZE = 100
|
||||||
// ...which comes 10,000k follows
|
// ...which comes 10,000k follows
|
||||||
|
|
||||||
export const RQKEY = () => ['my-follows']
|
export const RQKEY = (sessionDid: string | undefined) => [
|
||||||
|
'my-follows',
|
||||||
|
sessionDid,
|
||||||
|
]
|
||||||
|
|
||||||
export function useMyFollowsQuery() {
|
export function useMyFollowsQuery() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
return useQuery<AppBskyActorDefs.ProfileViewBasic[]>({
|
return useQuery<AppBskyActorDefs.ProfileViewBasic[]>({
|
||||||
staleTime: STALE.MINUTES.ONE,
|
staleTime: STALE.MINUTES.ONE,
|
||||||
queryKey: RQKEY(),
|
queryKey: RQKEY(currentAccount?.did),
|
||||||
async queryFn() {
|
queryFn: myFollowsQueryFn,
|
||||||
if (!currentAccount) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
let cursor
|
|
||||||
let arr: AppBskyActorDefs.ProfileViewBasic[] = []
|
|
||||||
for (let i = 0; i < SANITY_PAGE_LIMIT; i++) {
|
|
||||||
const res = await getAgent().getFollows({
|
|
||||||
actor: currentAccount.did,
|
|
||||||
cursor,
|
|
||||||
limit: PAGE_SIZE,
|
|
||||||
})
|
|
||||||
// TODO
|
|
||||||
// res.data.follows = res.data.follows.filter(
|
|
||||||
// profile =>
|
|
||||||
// !moderateProfile(profile, this.rootStore.preferences.moderationOpts)
|
|
||||||
// .account.filter,
|
|
||||||
// )
|
|
||||||
arr = arr.concat(res.data.follows)
|
|
||||||
if (!res.data.cursor) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
cursor = res.data.cursor
|
|
||||||
}
|
|
||||||
return arr
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function myFollowsQueryFn({queryKey}: QueryFunctionContext) {
|
||||||
|
const [_, sessionDid] = queryKey as ReturnType<typeof RQKEY>
|
||||||
|
if (!sessionDid) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
let cursor
|
||||||
|
let arr: AppBskyActorDefs.ProfileViewBasic[] = []
|
||||||
|
for (let i = 0; i < SANITY_PAGE_LIMIT; i++) {
|
||||||
|
const res = await getAgent().getFollows({
|
||||||
|
actor: sessionDid,
|
||||||
|
cursor,
|
||||||
|
limit: PAGE_SIZE,
|
||||||
|
})
|
||||||
|
// TODO
|
||||||
|
// res.data.follows = res.data.follows.filter(
|
||||||
|
// profile =>
|
||||||
|
// !moderateProfile(profile, this.rootStore.preferences.moderationOpts)
|
||||||
|
// .account.filter,
|
||||||
|
// )
|
||||||
|
arr = arr.concat(res.data.follows)
|
||||||
|
if (!res.data.cursor) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
cursor = res.data.cursor
|
||||||
|
}
|
||||||
|
return arr
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user