From 9dd79ca77ecb46dd0ea616945daa21d49fea5ee8 Mon Sep 17 00:00:00 2001 From: sundasnoreen12 <72802712+sundasnoreen12@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:56:04 +0500 Subject: [PATCH] fix: fixed empty section issue (#1292) * fix: fixed empty section issue * refactor: added checks to hide view --- src/courseware/course/new-sidebar/Sidebar.jsx | 4 ++-- src/courseware/course/new-sidebar/SidebarContextProvider.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/courseware/course/new-sidebar/Sidebar.jsx b/src/courseware/course/new-sidebar/Sidebar.jsx index cd8d3fd522..e8debc661c 100644 --- a/src/courseware/course/new-sidebar/Sidebar.jsx +++ b/src/courseware/course/new-sidebar/Sidebar.jsx @@ -4,9 +4,9 @@ import SidebarContext from './SidebarContext'; import { SIDEBARS } from './sidebars'; const Sidebar = () => { - const { currentSidebar } = useContext(SidebarContext); + const { currentSidebar, isDiscussionbarAvailable, isNotificationbarAvailable } = useContext(SidebarContext); - if (currentSidebar === null) { return null; } + if (currentSidebar === null || (!isDiscussionbarAvailable && !isNotificationbarAvailable)) { return null; } const SidebarToRender = SIDEBARS[currentSidebar].Sidebar; return ( diff --git a/src/courseware/course/new-sidebar/SidebarContextProvider.jsx b/src/courseware/course/new-sidebar/SidebarContextProvider.jsx index 5f38c72edc..679f083cb4 100644 --- a/src/courseware/course/new-sidebar/SidebarContextProvider.jsx +++ b/src/courseware/course/new-sidebar/SidebarContextProvider.jsx @@ -32,7 +32,7 @@ const SidebarProvider = ({ ); const topic = useModel('discussionTopics', unitId); const { verifiedMode } = useModel('courseHomeMeta', courseId); - const isDiscussionbarAvailable = topic?.id && topic?.enabledInContext; + const isDiscussionbarAvailable = (topic?.id && topic?.enabledInContext) || false; const isNotificationbarAvailable = !isEmpty(verifiedMode); const onNotificationSeen = useCallback(() => {