Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Memoize achievement inferencer #3061

Merged
merged 1 commit into from
Oct 8, 2024
Merged

Conversation

RichDom2185
Copy link
Member

Description

Uses a per-component instance singleton and memoizes it, as we only need to keep track of the initial states of the control panel.

Also added a TODO comment for future refactoring to more modern React principles using component state and hooks.

Closes #3060.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

Checklist

  • I have tested this code
  • I have updated the documentation

Uses a per-component instance singleton and memoizes it, as we only need
to keep track of the initial states of the control panel.

Also added a TODO comment for future refactoring to more modern React
principles using component state and hooks.
@RichDom2185 RichDom2185 self-assigned this Oct 8, 2024
@RichDom2185 RichDom2185 enabled auto-merge (squash) October 8, 2024 10:14
Comment on lines +41 to +44
const [initialAchievements, initialGoals] = useTypedSelector(state => [
state.achievement.achievements,
state.achievement.goals
]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useTypedSelector automatically listens to any state changes and reruns the callback, resulting in a new instance of the inferencer created each time the state is updated. This led to the bugged behaviour where it could not keep track of the state of the newly added (unpublished) goals and achievements.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11233333849

Details

  • 0 of 3 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.001%) to 31.454%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/pages/achievement/control/AchievementControl.tsx 0 3 0.0%
Totals Coverage Status
Change from base Build 11175613041: -0.001%
Covered Lines: 4855
Relevant Lines: 14551

💛 - Coveralls

@RichDom2185 RichDom2185 merged commit 8213d21 into master Oct 8, 2024
8 checks passed
@RichDom2185 RichDom2185 deleted the fix-goal-creation-failure branch October 8, 2024 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot create custom achievements or goals
3 participants