Skip to content

Commit

Permalink
fix: achievements loading and assessment workspace 404 (#3073)
Browse files Browse the repository at this point in the history
* Fix achievement inferencer memoization

It was previously not reupdating properly when new data is fetched from
the backend.

* Fix errorneous 404 on individual assessments
  • Loading branch information
RichDom2185 authored Oct 29, 2024
1 parent 864a641 commit 105546f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/commons/assessmentWorkspace/AssessmentWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
}, []);

useEffect(() => {
handleTeamOverviewFetch(props.assessmentId);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
if (assessmentOverview && assessmentOverview.maxTeamSize > 1) {
handleTeamOverviewFetch(props.assessmentId);
}
}, [assessmentOverview, handleTeamOverviewFetch, props.assessmentId]);

/**
* After mounting (either an older copy of the assessment
Expand Down
7 changes: 1 addition & 6 deletions src/pages/achievement/control/AchievementControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,13 @@ const AchievementControl: React.FC = () => {
[dispatch]
);

// TODO: This is a hacky fix. By right, we shouldn't need to use an
// inferencer instance since we can encapsulate the logic using hooks
// and component state.
const [initialAchievements, initialGoals] = useTypedSelector(state => [
state.achievement.achievements,
state.achievement.goals
]);
const inferencer = useMemo(
() => new AchievementInferencer(initialAchievements, initialGoals),
// We only want to create the inferencer once
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
[initialAchievements, initialGoals]
);

/**
Expand Down

0 comments on commit 105546f

Please sign in to comment.