Correction appels multiples à la connexion
This commit is contained in:
parent
afcb5427af
commit
55aff5f900
@ -1,6 +1,6 @@
|
|||||||
import { Href, useRouter } from 'expo-router'
|
import { Href, useRouter } from 'expo-router'
|
||||||
import { useRouteInfo } from 'expo-router/build/hooks'
|
import { useRouteInfo } from 'expo-router/build/hooks'
|
||||||
import { ReactNode, useEffect } from 'react'
|
import React, { ReactNode, useEffect } from 'react'
|
||||||
import { useAuth, useAuthLogin } from '@/hooks/useAuth'
|
import { useAuth, useAuthLogin } from '@/hooks/useAuth'
|
||||||
import * as SecureStore from '@/utils/SecureStore'
|
import * as SecureStore from '@/utils/SecureStore'
|
||||||
import { useLoginMutation } from '@/hooks/mutations/useLoginMutation'
|
import { useLoginMutation } from '@/hooks/mutations/useLoginMutation'
|
||||||
@ -47,7 +47,7 @@ export default function LoginProvider({ loginRedirect, children }: Props) {
|
|||||||
// Renouvellement auto du jeton d'authentification
|
// Renouvellement auto du jeton d'authentification
|
||||||
const { name, token } = auth
|
const { name, token } = auth
|
||||||
const password = SecureStore.getItem('apiPassword')
|
const password = SecureStore.getItem('apiPassword')
|
||||||
if (name === null || (password === null && token === null))
|
if (name === null || (password === null && token === null) || loginMutation.isPending)
|
||||||
return
|
return
|
||||||
let waitTime = 0
|
let waitTime = 0
|
||||||
if (token !== null && token !== undefined) {
|
if (token !== null && token !== undefined) {
|
||||||
@ -69,7 +69,7 @@ export default function LoginProvider({ loginRedirect, children }: Props) {
|
|||||||
authLogin({ name: name, token: null })
|
authLogin({ name: name, token: null })
|
||||||
}, waitTime)
|
}, waitTime)
|
||||||
return () => clearTimeout(timeout)
|
return () => clearTimeout(timeout)
|
||||||
}, [auth, authLogin, game, setPlayerId])
|
}, [auth, authLogin, loginMutation.status, game, setPlayerId])
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
{children}
|
{children}
|
||||||
|
Loading…
Reference in New Issue
Block a user