Conversation
OthmaneZ05
left a comment
There was a problem hiding this comment.
Thanks for the contribution, the overall approach looks good!This can create a race condition: if the user returns to the catalogue while the translation request is pending, the completed request can reopen the roadmap. Rapid language changes can also allow a stale response to win.
Could you invalidate or abort pending language reloads on cleanup and when closing the roadmap, and add tests for these cases?
| const translation = summaries.find( | ||
| summary => summary.id === roadmap.id && summary.language.split('-')[0] === base | ||
| ); | ||
| if (translation) openRoadmap(translation); |
There was a problem hiding this comment.
This can create a race condition: if the user returns to the catalogue while the translation request is pending, the completed request can reopen the roadmap. Rapid language changes can also allow a stale response to win.
Could you invalidate or abort pending language reloads on cleanup and when closing the roadmap, and add tests for these cases?
There was a problem hiding this comment.
Thanks! Pending loads are now invalidated when closing the roadmap, on unmount, and when the UI language switches back to the displayed one. Added a test for each case.
…age revert A translation load started by a UI language switch could land after the user went back to the catalogue (reopening the roadmap) or after the language switched back (flashing the stale translation, then reloading). cancelPendingOpen invalidates the in-flight openRoadmap; it now runs on close, on unmount, and when the UI returns to the displayed language.
96ae607 to
7577557
Compare
Summary of Changes
Fixes #101
An open roadmap kept its original language after the UI language was switched, while the rest of the UI and the catalogue switched correctly.
openRoadmapwas only called on card click or panel mount, so nothing reloaded the roadmap wheni18n.languagechanged.LearningPanelnow ownsuseRoadmaps()(single fetch on mount) and passes the catalogue state toRoadmapCatalogas a prop. The catalogue unmounts while a roadmap is open, so the list has to live one level up.LearningPanelreopens the open roadmap in its translation when the UI language changes. Languages are compared on the base subtag (fr-FRmatchesfr), same convention asfilterByUiLanguage.(id, language)match on the backend.Behavior notes:
openRoadmap, so the player returns to the first incomplete step and displayed validation results are cleared.Types of Changes
Verification & Testing
Automated Checks
npm run lintsuccessfully with no errorsnpm run buildsuccessfully with no compilation errorsnpm testsuccessfully (all tests pass)Three tests added in
LearningPanel.test.tsx:language=frand rendered in Frenchfrtofr-FR: no refetchManual Verification
enandfrChecklist