-
Notifications
You must be signed in to change notification settings - Fork 171
update session details with latest course information before switchin… #3083
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
base: master
Are you sure you want to change the base?
update session details with latest course information before switchin… #3083
Conversation
Pull Request Test Coverage Report for Build 14180292581Details
💛 - Coveralls |
987e9ba
to
e4e3749
Compare
Hi @RichDom2185, can you review this again? Thank you! |
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))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
enableGame
from the state of the current course to decide whether to route to the game page, or to route to another page. - this
enableGame
state 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.
…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/academyRoutes
checks for theenableGame
flag in the Redux store before deciding whether to redirect, but theenableGame
flag 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