Skip to content

Commit

Permalink
chore: make notification trigger default to open for audit user
Browse files Browse the repository at this point in the history
  • Loading branch information
leangseu-edx committed Nov 8, 2023
1 parent 9a0cdc0 commit 308f03c
Showing 1 changed file with 9 additions and 11 deletions.
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 Course = ({
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 Course = ({
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');
}

useEffect(() => {
Expand Down

0 comments on commit 308f03c

Please sign in to comment.