Skip to content

Commit 105546f

Browse files
authored
fix: achievements loading and assessment workspace 404 (#3073)
* Fix achievement inferencer memoization It was previously not reupdating properly when new data is fetched from the backend. * Fix errorneous 404 on individual assessments
1 parent 864a641 commit 105546f

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/commons/assessmentWorkspace/AssessmentWorkspace.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,10 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
191191
}, []);
192192

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

198199
/**
199200
* After mounting (either an older copy of the assessment

src/pages/achievement/control/AchievementControl.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,13 @@ const AchievementControl: React.FC = () => {
3535
[dispatch]
3636
);
3737

38-
// TODO: This is a hacky fix. By right, we shouldn't need to use an
39-
// inferencer instance since we can encapsulate the logic using hooks
40-
// and component state.
4138
const [initialAchievements, initialGoals] = useTypedSelector(state => [
4239
state.achievement.achievements,
4340
state.achievement.goals
4441
]);
4542
const inferencer = useMemo(
4643
() => new AchievementInferencer(initialAchievements, initialGoals),
47-
// We only want to create the inferencer once
48-
// eslint-disable-next-line react-hooks/exhaustive-deps
49-
[]
44+
[initialAchievements, initialGoals]
5045
);
5146

5247
/**

0 commit comments

Comments
 (0)