Remvoe locationFetched variable as it seemed to cause performance issues with rerenders

This commit is contained in:
Keannu Bernasol 2023-10-14 11:12:16 +08:00
parent 22820e139e
commit de33fe30fd

View file

@ -50,7 +50,6 @@ export default function Home() {
const map_distance_override = false; const map_distance_override = false;
const navigation = useNavigation<RootDrawerParamList>(); const navigation = useNavigation<RootDrawerParamList>();
const [location, setLocation] = useState<RawLocationType | null>(null); const [location, setLocation] = useState<RawLocationType | null>(null);
const [locationFetched, setLocationFetched] = useState(false);
const [locationPermitted, setLocationPermitted] = useState(false); const [locationPermitted, setLocationPermitted] = useState(false);
const [dist, setDist] = useState<number | null>(null); const [dist, setDist] = useState<number | null>(null);
const [feedback, setFeedback] = useState( const [feedback, setFeedback] = useState(
@ -103,6 +102,17 @@ export default function Home() {
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);
}, []); }, []);
@ -119,7 +129,6 @@ export default function Home() {
} }
setStopping(true); setStopping(true);
} }
setLocationFetched(true);
} }
// Student Status // Student Status
@ -364,7 +373,6 @@ export default function Home() {
function CustomMap() { function CustomMap() {
if (!locationPermitted) { if (!locationPermitted) {
console.log(locationPermitted);
return ( return (
<> <>
<Text style={styles.text_white_medium}>{feedback}</Text> <Text style={styles.text_white_medium}>{feedback}</Text>
@ -373,7 +381,7 @@ export default function Home() {
</Button> </Button>
</> </>
); );
} else if (dist && location && locationFetched) { } else if (dist && location) {
if (dist <= 1 || map_distance_override) { if (dist <= 1 || map_distance_override) {
if ( if (
(StudentStatusQuery.isFetching && studying) || (StudentStatusQuery.isFetching && studying) ||