Skip to content

Commit

Permalink
chore: update sidebar logic
Browse files Browse the repository at this point in the history
  • Loading branch information
leangseu-edx committed Nov 17, 2023
1 parent c38d69f commit 025eec7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/courseware/course/sidebar/SidebarContextProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ const SidebarProvider = ({
const [upgradeNotificationCurrentState, setUpgradeNotificationCurrentState] = useState(getLocalStorage(`upgradeNotificationCurrentState.${courseId}`));

useEffect(() => {
// if the user has not purchased the course or previously opened the notification tray, show the notification tray
const showNotificationsOnLoad = !!verifiedMode || getSessionStorage(`notificationTrayStatus.${courseId}`) !== 'closed';
// if the user left the tray open in the previous session, open it again
// if the user is not verified, open the tray iff the previous session was open and the user on large screen
const openBySession = getSessionStorage(`notificationTrayStatus.${courseId}`) !== 'closed';
const showNotificationsOnLoad = openBySession || (!!verifiedMode && shouldDisplaySidebarOpen && openBySession );

Check failure on line 33 in src/courseware/course/sidebar/SidebarContextProvider.jsx

View workflow job for this annotation

GitHub Actions / tests

There should be no space before this paren
if (showNotificationsOnLoad) {
setCurrentSidebar(SIDEBARS.NOTIFICATIONS.ID);
}
Expand Down
5 changes: 1 addition & 4 deletions src/data/sessionStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
function getSessionStorage(key) {
try {
if (global.sessionStorage) {
const rawItem = global.sessionStorage.getItem(key);
if (rawItem) {
return JSON.parse(rawItem);
}
return global.sessionStorage.getItem(key);
}
} catch (e) {
// If this fails for some reason, just return null.
Expand Down

0 comments on commit 025eec7

Please sign in to comment.