From 47ec3da6df4b715fe98a9741b877df7e150ed08a Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Thu, 12 Dec 2024 23:02:02 +0100 Subject: [PATCH] =?UTF-8?q?Meilleure=20fluidit=C3=A9=20lorsqu'un=20tire=20?= =?UTF-8?q?un=20d=C3=A9fi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/app/(tabs)/challenges.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/app/(tabs)/challenges.tsx b/client/app/(tabs)/challenges.tsx index 647aea7..61514ff 100644 --- a/client/app/(tabs)/challenges.tsx +++ b/client/app/(tabs)/challenges.tsx @@ -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)