mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
Added stop-gaps to help with refreshing queries on slower connections and increased refresh interval for homepage from 15 seconds to 10 seconds
This commit is contained in:
parent
e54fe893a0
commit
7b175c44df
3 changed files with 14 additions and 5 deletions
|
@ -43,7 +43,6 @@ export default function CreateGroup({ route }: any) {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["user"] });
|
queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||||
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
||||||
queryClient.invalidateQueries({ queryKey: ["study_group_list"] });
|
|
||||||
student_status_patch.mutate({
|
student_status_patch.mutate({
|
||||||
study_group: name,
|
study_group: name,
|
||||||
});
|
});
|
||||||
|
@ -75,13 +74,18 @@ export default function CreateGroup({ route }: any) {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["user"] });
|
queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||||
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["user_status_list"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["study_group_list"] });
|
||||||
toast.show(`Joined group ${name} successfully`, {
|
toast.show(`Joined group ${name} successfully`, {
|
||||||
type: "success",
|
type: "success",
|
||||||
placement: "top",
|
placement: "top",
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
animationType: "slide-in",
|
animationType: "slide-in",
|
||||||
});
|
});
|
||||||
navigation.navigate("Home");
|
// Set a delay before going back to homepage to hopefully let the queries refresh in time
|
||||||
|
setTimeout(() => {
|
||||||
|
navigation.navigate("Home");
|
||||||
|
}, 200);
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: (error: Error) => {
|
||||||
toast.show(String(error), {
|
toast.show(String(error), {
|
||||||
|
|
|
@ -93,11 +93,11 @@ export default function Home() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh every 15 seconds
|
// Refresh every 10 seconds
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
requestLocation();
|
requestLocation();
|
||||||
}, 15000);
|
}, 10000);
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
});
|
});
|
||||||
|
|
|
@ -79,13 +79,18 @@ export default function StartStudying({ route }: any) {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["user"] });
|
queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||||
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["user_status_list"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["study_group_list"] });
|
||||||
toast.show("You are now studying \n" + selected_subject, {
|
toast.show("You are now studying \n" + selected_subject, {
|
||||||
type: "success",
|
type: "success",
|
||||||
placement: "top",
|
placement: "top",
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
animationType: "slide-in",
|
animationType: "slide-in",
|
||||||
});
|
});
|
||||||
navigation.navigate("Home");
|
// Set a delay before going back to homepage to hopefully let the queries refresh in time
|
||||||
|
setTimeout(() => {
|
||||||
|
navigation.navigate("Home");
|
||||||
|
}, 200);
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: (error: Error) => {
|
||||||
toast.show(String(error), {
|
toast.show(String(error), {
|
||||||
|
|
Loading…
Reference in a new issue