Homepage optimizations

This commit is contained in:
Keannu Bernasol 2023-10-15 12:27:49 +08:00
parent b82b9d332f
commit ecf62a1008

View file

@ -111,8 +111,8 @@ export default function Home() {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ["study_group_list"], queryKey: ["study_group_list"],
}); });
requestLocation();
}, 2000); }, 2000);
requestLocation();
return () => clearInterval(interval); return () => clearInterval(interval);
}, []); }, []);
@ -121,12 +121,10 @@ export default function Home() {
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 && !stopping_toofar) {
if (!stopping_toofar) { stop_studying.mutate({
stop_studying.mutate({ active: false,
active: false, });
});
}
setStopping(true); setStopping(true);
} }
} }
@ -382,23 +380,22 @@ export default function Home() {
</> </>
); );
} else if (dist && location) { } else if (dist && location) {
if (dist <= 1 || map_distance_override) { if (
if ( (StudentStatusQuery.isFetching && studying) ||
(StudentStatusQuery.isFetching && studying) || StudentStatusListQuery.isFetching ||
StudentStatusListQuery.isFetching || StudyGroupQuery.isFetching ||
StudyGroupQuery.isFetching || (StudentStatusQuery.isFetching && !studying) ||
(StudentStatusQuery.isFetching && !studying) || StudentStatusListGlobalQuery.isFetching ||
StudentStatusListGlobalQuery.isFetching || StudyGroupGlobalQuery.isFetching
StudyGroupGlobalQuery.isFetching ) {
) { return (
return ( <>
<> <View style={{ paddingVertical: 8 }} />
<View style={{ paddingVertical: 8 }} /> <ActivityIndicator size={96} color={colors.secondary_1} />
<ActivityIndicator size={96} color={colors.secondary_1} /> <Text style={styles.text_white_medium}>Loading...</Text>
<Text style={styles.text_white_medium}>Loading...</Text> </>
</> );
); } else if (dist <= 1 || map_distance_override) {
}
return ( return (
<> <>
<View style={{ alignSelf: "flex-end" }}> <View style={{ alignSelf: "flex-end" }}>