mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
Fixed map elements not rendering on first open when on poor network conditions
This commit is contained in:
parent
8e5e0546df
commit
4caf86c6be
1 changed files with 14 additions and 9 deletions
|
@ -91,25 +91,30 @@ export default function Home() {
|
||||||
newLocation.coords.longitude !== location.coords.longitude
|
newLocation.coords.longitude !== location.coords.longitude
|
||||||
) {
|
) {
|
||||||
setLocation(newLocation);
|
setLocation(newLocation);
|
||||||
DistanceHandler(newLocation);
|
await DistanceHandler(newLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh every 10 seconds
|
// Refresh when screen loads & every 10 seconds
|
||||||
|
requestLocation();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
requestLocation();
|
requestLocation();
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
setTimeout(() => {
|
||||||
return () => clearInterval(interval);
|
queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||||
});
|
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
||||||
|
queryClient.invalidateQueries({
|
||||||
// Refresh when screen loads
|
queryKey: ["user_status_list"],
|
||||||
requestLocation();
|
});
|
||||||
useEffect(() => {
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["study_group_list"],
|
||||||
|
});
|
||||||
|
}, 2000);
|
||||||
requestLocation();
|
requestLocation();
|
||||||
|
return () => clearInterval(interval);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function DistanceHandler(location: RawLocationType) {
|
async function DistanceHandler(location: RawLocationType) {
|
||||||
|
|
Loading…
Reference in a new issue