De-closure invites
This commit is contained in:
@@ -16,21 +16,23 @@ export function useInviteCodesQuery() {
|
||||
return useQuery({
|
||||
staleTime: STALE.HOURS.ONE,
|
||||
queryKey: ['inviteCodes'],
|
||||
queryFn: async () => {
|
||||
const res = await getAgent().com.atproto.server.getAccountInviteCodes({})
|
||||
|
||||
if (!res.data?.codes) {
|
||||
throw new Error(`useInviteCodesQuery: no codes returned`)
|
||||
}
|
||||
|
||||
const available = res.data.codes.filter(isInviteAvailable)
|
||||
const used = res.data.codes.filter(code => !isInviteAvailable(code))
|
||||
|
||||
return {
|
||||
all: [...available, ...used],
|
||||
available,
|
||||
used,
|
||||
}
|
||||
},
|
||||
queryFn: inviteCodesQueryFn,
|
||||
})
|
||||
}
|
||||
|
||||
async function inviteCodesQueryFn() {
|
||||
const res = await getAgent().com.atproto.server.getAccountInviteCodes({})
|
||||
|
||||
if (!res.data?.codes) {
|
||||
throw new Error(`useInviteCodesQuery: no codes returned`)
|
||||
}
|
||||
|
||||
const available = res.data.codes.filter(isInviteAvailable)
|
||||
const used = res.data.codes.filter(code => !isInviteAvailable(code))
|
||||
|
||||
return {
|
||||
all: [...available, ...used],
|
||||
available,
|
||||
used,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user