update session details with latest course information before switchin…#3083
Open
C-likethis123 wants to merge 4 commits intosource-academy:masterfrom
Open
update session details with latest course information before switchin…#3083C-likethis123 wants to merge 4 commits intosource-academy:masterfrom
C-likethis123 wants to merge 4 commits intosource-academy:masterfrom
Conversation
Pull Request Test Coverage Report for Build 14180292581Details
💛 - Coveralls |
987e9ba to
e4e3749
Compare
Author
|
Hi @RichDom2185, can you review this again? Thank you! |
RichDom2185
reviewed
Feb 20, 2025
| const onChangeHandler = (e: React.ChangeEvent<HTMLSelectElement>) => { | ||
| navigate(`/courses/${e.currentTarget.value}`); | ||
| const onChangeHandler = async (e: React.ChangeEvent<HTMLSelectElement>) => { | ||
| await dispatch(SessionActions.updateLatestViewedCourse(Number(e.currentTarget.value))); |
Member
Author
There was a problem hiding this comment.
Hi @RichDom2185, thank you for the feedback and sorry for the late reply.
I agree that the logic is odd - here's my reasoning behind the change:
- when switching between courses, the router uses
enableGamefrom the state of the current course to decide whether to route to the game page, or to route to another page. - this
enableGamestate is based on the current course, not the course that the user wants to navigate to. - the state is only updated via an API call after the routing logic kicks in and the user finishes navigation to a page.
- the idea behind awaiting the dispatch call is to update the state of the latest viewed course to the course that I am trying to navigate to, before the routing logic kicks in
I can try to explore handling the async logic via sagas, but another suggestion from me is to enforce a navigation to a page that is common among all courses (eg the home page) so we don't have to use this conditional logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

…g courses
Description
Fixes the bug where switching courses redirects the user to the 'game' page, even when games are not enabled for the course.
The reason for this bug is because the loader function at
src/pages/academy/academyRouteschecks for theenableGameflag in the Redux store before deciding whether to redirect, but theenableGameflag value belongs to the previous course and not the course it's about to switch to. The solution adopted in this MR is to update the latest viewed course to the course that the user is about to navigate to, before actually navigating to that course.Screen.Recording.2025-01-31.at.12.30.06.AM.mov
Closes #3040.
Type of change
How to test
Checklist