diff --git a/src/routes/CreateGroup/CreateGroup.tsx b/src/routes/CreateGroup/CreateGroup.tsx index 296b5d8..904d472 100644 --- a/src/routes/CreateGroup/CreateGroup.tsx +++ b/src/routes/CreateGroup/CreateGroup.tsx @@ -43,7 +43,6 @@ export default function CreateGroup({ route }: any) { onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["user"] }); queryClient.invalidateQueries({ queryKey: ["user_status"] }); - queryClient.invalidateQueries({ queryKey: ["study_group_list"] }); student_status_patch.mutate({ study_group: name, }); @@ -75,13 +74,18 @@ export default function CreateGroup({ route }: any) { onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["user"] }); queryClient.invalidateQueries({ queryKey: ["user_status"] }); + queryClient.invalidateQueries({ queryKey: ["user_status_list"] }); + queryClient.invalidateQueries({ queryKey: ["study_group_list"] }); toast.show(`Joined group ${name} successfully`, { type: "success", placement: "top", duration: 2000, 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) => { toast.show(String(error), { diff --git a/src/routes/Home/Home.tsx b/src/routes/Home/Home.tsx index 81c4ec9..52dcd3f 100644 --- a/src/routes/Home/Home.tsx +++ b/src/routes/Home/Home.tsx @@ -93,11 +93,11 @@ export default function Home() { } } - // Refresh every 15 seconds + // Refresh every 10 seconds useEffect(() => { const interval = setInterval(() => { requestLocation(); - }, 15000); + }, 10000); return () => clearInterval(interval); }); diff --git a/src/routes/StartStudying/StartStudying.tsx b/src/routes/StartStudying/StartStudying.tsx index fdeeced..1656482 100644 --- a/src/routes/StartStudying/StartStudying.tsx +++ b/src/routes/StartStudying/StartStudying.tsx @@ -79,13 +79,18 @@ export default function StartStudying({ route }: any) { onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["user"] }); 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, { type: "success", placement: "top", duration: 2000, 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) => { toast.show(String(error), {