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

Ticket-88 #384

Merged
merged 7 commits into from
Jul 30, 2024
Merged

Ticket-88 #384

merged 7 commits into from
Jul 30, 2024

Conversation

divitcr7
Copy link
Contributor

added notification banner after completion of study

@chrisbendel
Copy link
Collaborator

@divitcr7 it looks like there are changes that revert to an older version of the study landing page - is this intended?

@chrisbendel
Copy link
Collaborator

@divitcr7 also could you please update the PR title to something more descriptive, thanks!

@divitcr7
Copy link
Contributor Author

This ticket details was changed initially after the task was done,
https://openstax.atlassian.net/browse/RENG-88

as per the ticket we were first supposed to create a study banner, but as per the discussion only the notifications banner on the top right of the screen was supposed to be added , tht stated the no. of points

import Markdown from 'react-markdown'
import { useLearningPathStudies } from './learner/studies';
import { CompactStudyCard } from '../components/study/compact-study-card';
import { notifications } from '@mantine/notifications';

let notificationShownThisSession = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont think we should be doing it this way - we don't want to be modifying a variable outside of the component state.


return () => clearTimeout(timer);
}
}, [study.totalPoints]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens if you remove study.totalPoints from the dependency array? ideally this should just run once when the component renders initially right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes but, when i did that for some weird reason, the notifcations got displayed twice, one above another like this:
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

this could be just a side effect of react rendering components twice in dev mode

// Reset the flag when the component unmounts
useEffect(() => {
return () => {
notificationShownThisSession = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove this RE: above comment

@chrisbendel
Copy link
Collaborator

@divitcr7 did you confirm if it was just the react strictmode/local dev server that was causing the double render? i think we should remove the useState for notificationShown if possible... should be unneeded if thats what it is? cc @Coder-Srinivas - curious what you think

@nathanstitt
Copy link
Member

nathanstitt commented Jul 26, 2024 via email

@chrisbendel chrisbendel merged commit 4171dde into main Jul 30, 2024
4 checks passed
@chrisbendel chrisbendel deleted the Ticket-88 branch July 30, 2024 13:07
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.

3 participants