Skip to content

Commit

Permalink
fix: wrong pod content (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomicvladan committed Oct 4, 2023
1 parent 1d5575a commit c630b7b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/Dropdowns/PodDropdown/PodDropdownToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import PageDownDark from '@media/UI/page-down-dark.svg';

const PodDropdownToggele = () => {
const { theme } = useContext(ThemeContext);
const { activePod, setActivePod, setDirectoryName } = useContext(PodContext);
const { loading, activePod, setActivePod, setDirectoryName } =
useContext(PodContext);
const { intl } = useLocales();

const onBackToDrive = () => {
Expand All @@ -36,6 +37,7 @@ const PodDropdownToggele = () => {
/>
)}
<Menu.Button
disabled={loading}
className={`flex items-center w-full cursor-pointer ${
activePod ? '' : 'pl-4'
}`}
Expand Down
13 changes: 11 additions & 2 deletions src/components/NavigationBars/DriveSideBar/DriveSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ import { useLocales } from '@context/LocalesContext';

const DriveSideBar: FC = () => {
const { theme } = useContext(ThemeContext);
const { pods, setPods, activePod, setActivePod, setDirectoryName } =
useContext(PodContext);
const {
loading: podLoading,
pods,
setPods,
activePod,
setActivePod,
setDirectoryName,
} = useContext(PodContext);
const { fdpClientRef } = useFdpStorage();
const [loading, setLoading] = useState(false);

Expand Down Expand Up @@ -55,6 +61,9 @@ const DriveSideBar: FC = () => {
};

const handleOpenPod = (podName: string) => {
if (podLoading) {
return;
}
setActivePod(podName);
setDirectoryName('root');
};
Expand Down
8 changes: 8 additions & 0 deletions src/context/PodContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { GetPodResponse } from '@api/pod';
import { FC, ReactNode, createContext, useState } from 'react';

interface PodContext {
loading: boolean;
setLoading: (loading: boolean) => void;
pods: GetPodResponse;
setPods: (pods: GetPodResponse) => void;
activePod: string;
Expand All @@ -20,6 +22,8 @@ interface PodContextProps {
}

const podContextDefaultValues: PodContext = {
loading: false,
setLoading: () => {},
pods: { pod_name: [], shared_pod_name: [] },
setPods: (pods: GetPodResponse) => {},
activePod: '',
Expand All @@ -34,12 +38,14 @@ const podContextDefaultValues: PodContext = {
const PodContext = createContext<PodContext>(podContextDefaultValues);

const PodProvider: FC<PodContextProps> = ({ children }) => {
const [loading, setLoading] = useState<boolean>(false);
const [pods, setPods] = useState(null);
const [activePod, setActivePod] = useState('');
const [openPods, setOpenPods] = useState([]);
const [directoryName, setDirectoryName] = useState('');

const clearPodContext = () => {
setLoading(false);
setPods(null);
setActivePod('');
setOpenPods([]);
Expand All @@ -49,6 +55,8 @@ const PodProvider: FC<PodContextProps> = ({ children }) => {
return (
<PodContext.Provider
value={{
loading,
setLoading,
pods,
setPods,
activePod,
Expand Down
3 changes: 2 additions & 1 deletion src/pages/drive/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const Drive: FC = () => {
const { trackPageView } = useMatomo();
const { theme } = useContext(ThemeContext);
const {
loading,
setLoading,
pods,
activePod,
setActivePod,
Expand All @@ -60,7 +62,6 @@ const Drive: FC = () => {
const [previewFile, setPreviewFile] = useState(null);
const [driveView, setDriveView] = useState<'grid' | 'list'>('grid');
const [driveSort, setDriveSort] = useState('a-z');
const [loading, setLoading] = useState(false);
const { fdpClientRef, getAccountAddress } = useFdpStorage();

useEffect(() => {
Expand Down

0 comments on commit c630b7b

Please sign in to comment.