From 7e30d12b5279e01060b7606e9319f98fc006fd37 Mon Sep 17 00:00:00 2001 From: Ren Date: Sun, 8 Oct 2023 07:37:26 +0700 Subject: [PATCH] Trigger unlock on main and also handle 422 --- src/components/module/dashboard/main/MainPage.tsx | 4 ++++ src/pages/_app.tsx | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/module/dashboard/main/MainPage.tsx b/src/components/module/dashboard/main/MainPage.tsx index 9600966..888a194 100644 --- a/src/components/module/dashboard/main/MainPage.tsx +++ b/src/components/module/dashboard/main/MainPage.tsx @@ -65,6 +65,10 @@ function ServiceRow({ chall }: ServiceRowProps) { export default function MainPage() { const { isLoading, error, data } = useUserChallenges(); + useQuery({ + queryKey: ["unlocked"], + queryFn: () => getUser("my/solves"), + }); const [flag, setFlag] = useState(""); const submitFlag = useMutation({ mutationFn: (flag: string) => diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 1678923..62aa619 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -38,7 +38,10 @@ export default function App({ Component, pageProps }: AppPropsWithLayout) { queryCache: new QueryCache({ onError(error, query) { if (error instanceof HTTPError) { - if (error.response.status === 403) { + if ( + error.response.status === 403 || + error.response.status === 422 + ) { const jotaiStore = getDefaultStore(); jotaiStore.set(authTokenAtom, ""); }