[Session] Add useAgent hook and replace (#3706)
* Hook it up * Memoize getAgent method * Use one shared reference --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
This commit is contained in:
parent
d8c8e1e854
commit
45d354cd0c
53 changed files with 231 additions and 114 deletions
|
|
@ -3,7 +3,7 @@ import {useQuery} from '@tanstack/react-query'
|
|||
|
||||
import {cleanError} from '#/lib/strings/errors'
|
||||
import {STALE} from '#/state/queries'
|
||||
import {getAgent} from '#/state/session'
|
||||
import {useAgent} from '#/state/session'
|
||||
|
||||
function isInviteAvailable(invite: ComAtprotoServerDefs.InviteCode): boolean {
|
||||
return invite.available - invite.uses.length > 0 && !invite.disabled
|
||||
|
|
@ -16,6 +16,7 @@ export type InviteCodesQueryResponse = Exclude<
|
|||
undefined
|
||||
>
|
||||
export function useInviteCodesQuery() {
|
||||
const {getAgent} = useAgent()
|
||||
return useQuery({
|
||||
staleTime: STALE.MINUTES.FIVE,
|
||||
queryKey: [inviteCodesQueryKeyRoot],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue