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

chore: make notification trigger default to open for audit user #1233

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/courseware/course/Course.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
const {
celebrations,
isStaff,
verifiedMode,
} = useModel('courseHomeMeta', courseId);
const sequence = useModel('sequences', sequenceId);
const section = useModel('sections', sequence ? sequence.sectionId : null);
Expand All @@ -54,17 +55,14 @@
const shouldDisplayTriggers = windowWidth >= breakpoints.small.minWidth;
const daysPerWeek = course?.courseGoals?.selectedGoal?.daysPerWeek;

// Responsive breakpoints for showing the notification button/tray
const shouldDisplayNotificationTrayOpenOnLoad = windowWidth > breakpoints.medium.minWidth;

// Course specific notification tray open/closed persistance by browser session
if (!getSessionStorage(`notificationTrayStatus.${courseId}`)) {
if (shouldDisplayNotificationTrayOpenOnLoad) {
setSessionStorage(`notificationTrayStatus.${courseId}`, 'open');
} else {
// responsive version displays the tray closed on initial load, set the sessionStorage to closed
setSessionStorage(`notificationTrayStatus.${courseId}`, 'closed');
}
// 1. open the notification tray if the user has not purchased the course and is on a desktop
// 2. default to close on the first time access
// 3. use the last state if the user has access the course before
const shouldDisplayNotificationTrayOpenOnLoad = windowWidth > breakpoints.medium.minWidth && !!verifiedMode;
if (shouldDisplayNotificationTrayOpenOnLoad) {
setSessionStorage(`notificationTrayStatus.${courseId}`, 'open');
} else if (!getSessionStorage(`notificationTrayStatus.${courseId}`)) {
setSessionStorage(`notificationTrayStatus.${courseId}`, 'closed');

Check warning on line 65 in src/courseware/course/Course.jsx

View check run for this annotation

Codecov / codecov/patch

src/courseware/course/Course.jsx#L65

Added line #L65 was not covered by tests
}

useEffect(() => {
Expand Down