Skip to content

Commit

Permalink
add refetch
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpeng02 committed May 1, 2024
1 parent 0724b98 commit a0f4272
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/src/pages/train/[train_space_id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const mapTrainResultsDataToCharts = (

const TrainSpace = () => {
const { train_space_id } = useRouter().query;
const { data, isLoading } = useGetTrainResultsDataQuery({
const { data, isLoading, refetch, error } = useGetTrainResultsDataQuery({
trainspaceId: train_space_id,
});

Expand All @@ -163,6 +163,11 @@ const TrainSpace = () => {
router.replace({ pathname: "/login" });
}
}, [user, router.isReady]);

if (error) {
setTimeout(() => refetch(), 3000);
}

if (!isSignedIn(user) || !data || isLoading) {
return <></>;
}
Expand Down

0 comments on commit a0f4272

Please sign in to comment.