mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
Reverted query invalidation on mount in homepage as it was causing performance issues
This commit is contained in:
parent
4caf86c6be
commit
a11ff2ee6f
1 changed files with 13 additions and 16 deletions
|
@ -97,34 +97,28 @@ export default function Home() {
|
|||
}
|
||||
}
|
||||
|
||||
// Refresh when screen loads & every 10 seconds
|
||||
// Refresh every 10 seconds
|
||||
requestLocation();
|
||||
useEffect(() => {
|
||||
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);
|
||||
}, []);
|
||||
|
||||
const [stopping_toofar, setStopping] = useState(false);
|
||||
async function DistanceHandler(location: RawLocationType) {
|
||||
let dist = GetDistanceFromUSTP(location.coords);
|
||||
setDist(dist);
|
||||
// Deactivate student status if too far away and still studying
|
||||
if (dist >= 2 && !map_distance_override && studying)
|
||||
stop_studying.mutate({
|
||||
active: false,
|
||||
});
|
||||
if (dist >= 2 && !map_distance_override && studying) {
|
||||
if (!stopping_toofar) {
|
||||
stop_studying.mutate({
|
||||
active: false,
|
||||
});
|
||||
}
|
||||
setStopping(true);
|
||||
}
|
||||
setLocationFetched(true);
|
||||
}
|
||||
|
||||
|
@ -196,6 +190,9 @@ export default function Home() {
|
|||
}, 500);
|
||||
setStudyGroups([]);
|
||||
setStudying(false);
|
||||
if (stopping_toofar) {
|
||||
setStopping(false);
|
||||
}
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
toast.show(String(error), {
|
||||
|
|
Loading…
Reference in a new issue