Skip to content

Commit

Permalink
chore: make notification display by default
Browse files Browse the repository at this point in the history
  • Loading branch information
leangseu-edx committed Nov 8, 2023
1 parent 308f03c commit 91cb1f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/courseware/course/sidebar/SidebarContextProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import React, {
} from 'react';

import { getLocalStorage, setLocalStorage } from '../../../data/localStorage';
import { getSessionStorage } from '../../../data/sessionStorage';

import SidebarContext from './SidebarContext';
import { SIDEBARS } from './sidebars';

Expand All @@ -16,13 +18,16 @@ const SidebarProvider = ({
const shouldDisplayFullScreen = useWindowSize().width < breakpoints.large.minWidth;
const shouldDisplaySidebarOpen = useWindowSize().width > breakpoints.medium.minWidth;
const query = new URLSearchParams(window.location.search);
const showNotificationsOnLoad = getSessionStorage(`notificationTrayStatus.${courseId}`) !== 'closed';
const initialSidebar = (shouldDisplaySidebarOpen || query.get('sidebar') === 'true') ? SIDEBARS.DISCUSSIONS.ID : null;
const [currentSidebar, setCurrentSidebar] = useState(initialSidebar);
const [notificationStatus, setNotificationStatus] = useState(getLocalStorage(`notificationStatus.${courseId}`));
const [upgradeNotificationCurrentState, setUpgradeNotificationCurrentState] = useState(getLocalStorage(`upgradeNotificationCurrentState.${courseId}`));

useEffect(() => {
setCurrentSidebar(SIDEBARS.DISCUSSIONS.ID);
if (showNotificationsOnLoad) {
setCurrentSidebar( SIDEBARS.NOTIFICATIONS.ID );

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

View workflow job for this annotation

GitHub Actions / tests

There should be no space after this paren

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

View workflow job for this annotation

GitHub Actions / tests

There should be no space before this paren
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [unitId]);

Expand Down
2 changes: 1 addition & 1 deletion src/data/sessionStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getSessionStorage(key) {
function setSessionStorage(key, value) {
try {
if (global.sessionStorage) {
global.sessionStorage.setItem(key, JSON.stringify(value));
global.sessionStorage.setItem(key, value);
}
} catch (e) {
// If this fails, just bail.
Expand Down

0 comments on commit 91cb1f5

Please sign in to comment.