remove sidebar props from context

This commit is contained in:
Abhinav 2022-06-09 12:45:29 +05:30
parent 31b976fa87
commit 9d4e30d9ea
3 changed files with 14 additions and 13 deletions

View file

@ -1,4 +1,4 @@
import React, { useContext } from 'react';
import React from 'react';
import NavigationSection from './NavigationSection';
import UtilitySection from './UtilitySection';
@ -9,14 +9,17 @@ import { DrawerSidebar, PaddedDivider } from './styledComponents';
import HeaderSection from './Header';
import { CollectionSummaries } from 'types/collection';
import UserDetailsSection from './userDetailsSection';
import { GalleryContext } from 'pages/gallery';
interface Iprops {
collectionSummaries: CollectionSummaries;
sidebarView: boolean;
closeSidebar: () => void;
}
export default function Sidebar({ collectionSummaries }: Iprops) {
const { sidebarView, closeSidebar } = useContext(GalleryContext);
export default function Sidebar({
collectionSummaries,
sidebarView,
closeSidebar,
}: Iprops) {
return (
<DrawerSidebar open={sidebarView} onClose={closeSidebar}>
<HeaderSection closeSidebar={closeSidebar} />

View file

@ -130,8 +130,6 @@ const defaultGalleryContext: GalleryContextType = {
syncWithRemote: () => null,
setNotificationAttributes: () => null,
setBlockingLoad: () => null,
sidebarView: false,
closeSidebar: () => null,
};
export const GalleryContext = createContext<GalleryContextType>(
@ -204,7 +202,7 @@ export default function Gallery() {
const [electronFiles, setElectronFiles] = useState<ElectronFile[]>(null);
const [uploadTypeSelectorView, setUploadTypeSelectorView] = useState(false);
const [sidebarView, setSidebarView] = useState(false);
const [sidebarView, setSidebarView] = useState(true);
const closeSidebar = () => setSidebarView(false);
const openSidebar = () => setSidebarView(true);
@ -584,8 +582,6 @@ export default function Gallery() {
syncWithRemote,
setNotificationAttributes,
setBlockingLoad,
closeSidebar,
sidebarView,
}}>
<FullScreenDropZone
getRootProps={getRootProps}
@ -683,7 +679,11 @@ export default function Gallery() {
setUploadTypeSelectorView={setUploadTypeSelectorView}
showSessionExpiredMessage={showSessionExpiredMessage}
/>
<Sidebar collectionSummaries={collectionSummaries} />
<Sidebar
collectionSummaries={collectionSummaries}
sidebarView={sidebarView}
closeSidebar={closeSidebar}
/>
<PhotoFrame
files={files}

View file

@ -24,6 +24,4 @@ export type GalleryContextType = {
syncWithRemote: (force?: boolean, silent?: boolean) => Promise<void>;
setNotificationAttributes: (attributes: NotificationAttributes) => void;
setBlockingLoad: (value: boolean) => void;
sidebarView: boolean;
closeSidebar: () => void;
};