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();
|
requestLocation();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
requestLocation();
|
requestLocation();
|
||||||
}, 10000);
|
}, 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);
|
return () => clearInterval(interval);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const [stopping_toofar, setStopping] = useState(false);
|
||||||
async function DistanceHandler(location: RawLocationType) {
|
async function DistanceHandler(location: RawLocationType) {
|
||||||
let dist = GetDistanceFromUSTP(location.coords);
|
let dist = GetDistanceFromUSTP(location.coords);
|
||||||
setDist(dist);
|
setDist(dist);
|
||||||
// Deactivate student status if too far away and still studying
|
// Deactivate student status if too far away and still studying
|
||||||
if (dist >= 2 && !map_distance_override && studying)
|
if (dist >= 2 && !map_distance_override && studying) {
|
||||||
stop_studying.mutate({
|
if (!stopping_toofar) {
|
||||||
active: false,
|
stop_studying.mutate({
|
||||||
});
|
active: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setStopping(true);
|
||||||
|
}
|
||||||
setLocationFetched(true);
|
setLocationFetched(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +190,9 @@ export default function Home() {
|
||||||
}, 500);
|
}, 500);
|
||||||
setStudyGroups([]);
|
setStudyGroups([]);
|
||||||
setStudying(false);
|
setStudying(false);
|
||||||
|
if (stopping_toofar) {
|
||||||
|
setStopping(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: (error: Error) => {
|
||||||
toast.show(String(error), {
|
toast.show(String(error), {
|
||||||
|
|
Loading…
Reference in a new issue