From de33fe30fd72d127b25c60c5f954b63863f9a1db Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sat, 14 Oct 2023 11:12:16 +0800 Subject: [PATCH] Remvoe locationFetched variable as it seemed to cause performance issues with rerenders --- src/routes/Home/Home.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/routes/Home/Home.tsx b/src/routes/Home/Home.tsx index dadb0b2..2044956 100644 --- a/src/routes/Home/Home.tsx +++ b/src/routes/Home/Home.tsx @@ -50,7 +50,6 @@ export default function Home() { const map_distance_override = false; const navigation = useNavigation(); const [location, setLocation] = useState(null); - const [locationFetched, setLocationFetched] = useState(false); const [locationPermitted, setLocationPermitted] = useState(false); const [dist, setDist] = useState(null); const [feedback, setFeedback] = useState( @@ -103,6 +102,17 @@ export default function Home() { const interval = setInterval(() => { requestLocation(); }, 10000); + setTimeout(() => { + queryClient.invalidateQueries({ queryKey: ["user"] }); + queryClient.invalidateQueries({ queryKey: ["user_status"] }); + queryClient.invalidateQueries({ + queryKey: ["user_status_list"], + }); + queryClient.invalidateQueries({ + queryKey: ["study_group_list"], + }); + }, 2000); + requestLocation(); return () => clearInterval(interval); }, []); @@ -119,7 +129,6 @@ export default function Home() { } setStopping(true); } - setLocationFetched(true); } // Student Status @@ -364,7 +373,6 @@ export default function Home() { function CustomMap() { if (!locationPermitted) { - console.log(locationPermitted); return ( <> {feedback} @@ -373,7 +381,7 @@ export default function Home() { ); - } else if (dist && location && locationFetched) { + } else if (dist && location) { if (dist <= 1 || map_distance_override) { if ( (StudentStatusQuery.isFetching && studying) ||