This commit is contained in:
parent
fbb725dc93
commit
998484a682
@ -86,7 +86,6 @@ export default function PlayerScores({
|
|||||||
data: scores,
|
data: scores,
|
||||||
isError,
|
isError,
|
||||||
isLoading,
|
isLoading,
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["playerScores", player.id, pageState, debouncedSearchTerm],
|
queryKey: ["playerScores", player.id, pageState, debouncedSearchTerm],
|
||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
@ -97,7 +96,9 @@ export default function PlayerScores({
|
|||||||
...(isSearchActive && { search: debouncedSearchTerm }),
|
...(isSearchActive && { search: debouncedSearchTerm }),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
staleTime: 30 * 1000,
|
staleTime: 30 * 1000, // 30 seconds
|
||||||
|
enabled:
|
||||||
|
debouncedSearchTerm.length >= 3 || debouncedSearchTerm.length === 0, // Enable if valid search query or empty
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleScoreLoad = useCallback(async () => {
|
const handleScoreLoad = useCallback(async () => {
|
||||||
@ -127,10 +128,6 @@ export default function PlayerScores({
|
|||||||
);
|
);
|
||||||
}, [pageState, debouncedSearchTerm, player.id]);
|
}, [pageState, debouncedSearchTerm, player.id]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
refetch();
|
|
||||||
}, [pageState, debouncedSearchTerm, refetch]);
|
|
||||||
|
|
||||||
const handleSearchChange = (query: string) => {
|
const handleSearchChange = (query: string) => {
|
||||||
setSearchState({ query });
|
setSearchState({ query });
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user