Extract query key roots to constants (#3404)
* Extract query key roots to constants * Dedupe labelers-detailed-info * Align naming
This commit is contained in:
parent
b26abf212e
commit
b783745b2e
31 changed files with 202 additions and 143 deletions
|
|
@ -1,14 +1,16 @@
|
|||
import {ComAtprotoServerDefs} from '@atproto/api'
|
||||
import {useQuery} from '@tanstack/react-query'
|
||||
|
||||
import {getAgent} from '#/state/session'
|
||||
import {STALE} from '#/state/queries'
|
||||
import {cleanError} from '#/lib/strings/errors'
|
||||
import {STALE} from '#/state/queries'
|
||||
import {getAgent} from '#/state/session'
|
||||
|
||||
function isInviteAvailable(invite: ComAtprotoServerDefs.InviteCode): boolean {
|
||||
return invite.available - invite.uses.length > 0 && !invite.disabled
|
||||
}
|
||||
|
||||
const inviteCodesQueryKeyRoot = 'inviteCodes'
|
||||
|
||||
export type InviteCodesQueryResponse = Exclude<
|
||||
ReturnType<typeof useInviteCodesQuery>['data'],
|
||||
undefined
|
||||
|
|
@ -16,7 +18,7 @@ export type InviteCodesQueryResponse = Exclude<
|
|||
export function useInviteCodesQuery() {
|
||||
return useQuery({
|
||||
staleTime: STALE.MINUTES.FIVE,
|
||||
queryKey: ['inviteCodes'],
|
||||
queryKey: [inviteCodesQueryKeyRoot],
|
||||
queryFn: async () => {
|
||||
const res = await getAgent()
|
||||
.com.atproto.server.getAccountInviteCodes({})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue