fix: reset initialsidebar after shouldDisplaySidebarOpen (#1428)

* fix: reset initialsidebar after shouldDisplaySidebarOpen

* fix: fixed issue due to localstorage sidebar value when shifting from old to new one
This commit is contained in:
sundasnoreen12
2024-08-02 15:22:18 +05:00
committed by GitHub
parent 3a542766d7
commit 26199fa954
2 changed files with 6 additions and 1 deletions

View File

@@ -6,7 +6,8 @@ import { SIDEBARS } from './sidebars';
const Sidebar = () => {
const { currentSidebar, isDiscussionbarAvailable, isNotificationbarAvailable } = useContext(SidebarContext);
if (currentSidebar === null || (!isDiscussionbarAvailable && !isNotificationbarAvailable)) { return null; }
if (currentSidebar === null || (!isDiscussionbarAvailable && !isNotificationbarAvailable)
|| !SIDEBARS[currentSidebar]) { return null; }
const SidebarToRender = SIDEBARS[currentSidebar].Sidebar;
return (

View File

@@ -61,6 +61,10 @@ const SidebarProvider = ({
}
}, [hideDiscussionbar, hideNotificationbar]);
useEffect(() => {
setCurrentSidebar(initialSidebar);
}, [shouldDisplaySidebarOpen, initialSidebar]);
const handleWidgetToggle = useCallback((widgetId, sidebarId) => {
setHideDiscussionbar(prevWidgetId => (widgetId === WIDGETS.DISCUSSIONS ? true : prevWidgetId));
setHideNotificationbar(prevWidgetId => (widgetId === WIDGETS.NOTIFICATIONS ? true : prevWidgetId));