diff --git a/src/routes/CreateGroup/CreateGroup.tsx b/src/routes/CreateGroup/CreateGroup.tsx index 528cdc1..9ada1af 100644 --- a/src/routes/CreateGroup/CreateGroup.tsx +++ b/src/routes/CreateGroup/CreateGroup.tsx @@ -52,6 +52,7 @@ 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, }); diff --git a/src/routes/Home/Home.tsx b/src/routes/Home/Home.tsx index 8adfa3f..7d8f170 100644 --- a/src/routes/Home/Home.tsx +++ b/src/routes/Home/Home.tsx @@ -172,7 +172,13 @@ export default function Home() { }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["user"] }); - queryClient.invalidateQueries({ queryKey: ["user_status"] }); + queryClient.invalidateQueries({ queryKey: ["study_group_list_global"] }); + setTimeout(() => { + queryClient.invalidateQueries({ queryKey: ["user_status"] }); + queryClient.invalidateQueries({ queryKey: ["study_group_list"] }); + }, 500); + setStudyGroups([]); + setStudying(false); toast.show("You are no longer studying \n" + subject, { type: "success", placement: "top", @@ -190,34 +196,6 @@ export default function Home() { }, }); - const study_group_create = useMutation({ - mutationFn: async (info: StudyGroupCreateType) => { - const data = await CreateStudyGroup(info); - if (data[0] != true) { - return Promise.reject(new Error()); - } - return data; - }, - onSuccess: () => { - queryClient.invalidateQueries({ queryKey: ["user"] }); - queryClient.invalidateQueries({ queryKey: ["user_status"] }); - toast.show("Created successfully", { - type: "success", - placement: "top", - duration: 2000, - animationType: "slide-in", - }); - }, - onError: (error: Error) => { - toast.show(String(error), { - type: "warning", - placement: "top", - duration: 2000, - animationType: "slide-in", - }); - }, - }); - const [student_statuses, setStudentStatuses] = useState([]); // Student Status List @@ -251,7 +229,7 @@ export default function Home() { }); const [study_groups, setStudyGroups] = useState([]); - // Student Status List + // Study Group List const StudyGroupQuery = useQuery({ enabled: studying, queryKey: ["study_group_list"], @@ -281,7 +259,7 @@ export default function Home() { >([]); // Student Status List const StudyGroupGlobalQuery = useQuery({ - enabled: !studying, + enabled: !studying && !StudentStatusQuery.isFetching, queryKey: ["study_group_list_global"], queryFn: async () => { const data = await GetStudyGroupList(); @@ -420,11 +398,8 @@ export default function Home() {