Meilleure fluidité lorsqu'un tire un défi

This commit is contained in:
Emmy D'Anello 2024-12-12 23:02:02 +01:00
parent bd5e39094b
commit 47ec3da6df
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -6,6 +6,7 @@ import { useChallengeActions } from '@/hooks/useChallengeActions'
import { useChallenges } from '@/hooks/useChallenges'
import { useGame } from '@/hooks/useGame'
import { FontAwesome6 } from '@expo/vector-icons'
import { useQueryClient } from '@tanstack/react-query'
import { useEffect, useMemo, useState } from 'react'
import { View } from 'react-native'
import { ActivityIndicator, Appbar, Banner, FAB, MD3Colors, Surface, Text, TouchableRipple } from 'react-native-paper'
@ -21,6 +22,7 @@ function ChallengeScreenHeader() {
}
function ChallengeScreenBody() {
const queryClient = useQueryClient()
const auth = useAuth()
const game = useGame()
const challengeActions = useChallengeActions()
@ -38,7 +40,10 @@ function ChallengeScreenBody() {
const [loading, setLoading] = useState(false)
const drawRandomChallengeMutation = useDrawRandomChallengeMutation({
auth,
onPostSuccess: () => setLoading(true),
onPostSuccess: () => {
setLoading(true)
queryClient.invalidateQueries({ predicate: (query) => query.queryKey[0] === 'get-challenges' || query.queryKey[0] === 'get-player' })
}
})
useEffect(() => {
if (challengeActions)