Fixed map elements not rendering on first open when on poor network conditions

This commit is contained in:
Keannu Bernasol 2023-10-13 14:28:22 +08:00
parent 8e5e0546df
commit 4caf86c6be

View file

@ -91,25 +91,30 @@ export default function Home() {
newLocation.coords.longitude !== location.coords.longitude
) {
setLocation(newLocation);
DistanceHandler(newLocation);
await DistanceHandler(newLocation);
}
}
}
}
// Refresh every 10 seconds
// Refresh when screen loads & every 10 seconds
requestLocation();
useEffect(() => {
const interval = setInterval(() => {
requestLocation();
}, 10000);
return () => clearInterval(interval);
setTimeout(() => {
queryClient.invalidateQueries({ queryKey: ["user"] });
queryClient.invalidateQueries({ queryKey: ["user_status"] });
queryClient.invalidateQueries({
queryKey: ["user_status_list"],
});
// Refresh when screen loads
requestLocation();
useEffect(() => {
queryClient.invalidateQueries({
queryKey: ["study_group_list"],
});
}, 2000);
requestLocation();
return () => clearInterval(interval);
}, []);
async function DistanceHandler(location: RawLocationType) {