Skip to content

Commit

Permalink
chore: make sidebar less intrusive for mobile (openedx#1377)
Browse files Browse the repository at this point in the history
* chore: fix incorrect fetch result

* chore: make sidebar less intrusive for mobile

* chore: linting
  • Loading branch information
leangseu-edx authored May 14, 2024
1 parent 1857b86 commit 257c9dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/courseware/course/sidebar/SidebarContextProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const SidebarProvider = ({
const { alwaysOpenAuxiliarySidebar } = useSelector(getCoursewareOutlineSidebarSettings);
const isInitiallySidebarOpen = shouldDisplaySidebarOpen || query.get('sidebar') === 'true';

let initialSidebar = null;
if (isInitiallySidebarOpen && alwaysOpenAuxiliarySidebar) {
let initialSidebar = shouldDisplayFullScreen ? getLocalStorage(`sidebar.${courseId}`) : null;
if (!shouldDisplayFullScreen && isInitiallySidebarOpen && alwaysOpenAuxiliarySidebar) {
initialSidebar = isUnitHasDiscussionTopics
? SIDEBARS[discussionsSidebar.ID].ID
: verifiedMode && SIDEBARS[notificationsSidebar.ID].ID;
Expand Down Expand Up @@ -57,7 +57,9 @@ const SidebarProvider = ({

const toggleSidebar = useCallback((sidebarId) => {
// Switch to new sidebar or hide the current sidebar
setCurrentSidebar(sidebarId === currentSidebar ? null : sidebarId);
const newSidebar = sidebarId === currentSidebar ? null : sidebarId;
setCurrentSidebar(newSidebar);
setLocalStorage(`sidebar.${courseId}`, newSidebar);
}, [currentSidebar]);

const contextValue = useMemo(() => ({
Expand Down
2 changes: 1 addition & 1 deletion src/courseware/data/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function fetchCourse(courseId) {
logError(courseHomeMetadataResult.reason);
}
if (!fetchedCoursewareOutlineSidebarTogglesResult) {
logError(fetchedCoursewareOutlineSidebarTogglesResult.reason);
logError(coursewareOutlineSidebarTogglesResult.reason);
}
if (fetchedMetadata && fetchedCourseHomeMetadata) {
if (courseHomeMetadataResult.value.courseAccess.hasAccess && fetchedOutline) {
Expand Down

0 comments on commit 257c9dc

Please sign in to comment.