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)