Fix: Honkdex instances for older gens open as blank Gen 9 instances #237
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Bug:
( Fixes #233 )
When opening a saved Honkdex instance (e.g., Gen 3), the constructor in HonkdexBootstrappable.ts was initializing with the default generation (Gen 9) before checking the saved state.
This triggered the safety check if (this.calcdexState.gen !== this.gen), causing the app to treat the mismatch as invalid and generating a new random UUID (blank instance) instead of loading the saved data.
The Fix:
Updated the constructor to check if calcdexState exists for the provided instanceId. If it does, use the saved gen and format instead of the defaults.
Apologies if this misunderstands the architecture, I'm not very experienced with react. In particular, this fix ignores why this.gen is defaulting to gen 9 every time, but ¯\_(ツ)_/¯.