From c630b7bcc19ad1189976ab5cefcaaddc3967577e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladan=20Tomi=C4=87?= Date: Wed, 4 Oct 2023 11:57:56 +0200 Subject: [PATCH] fix: wrong pod content (#538) --- .../Dropdowns/PodDropdown/PodDropdownToggle.tsx | 4 +++- .../NavigationBars/DriveSideBar/DriveSideBar.tsx | 13 +++++++++++-- src/context/PodContext.tsx | 8 ++++++++ src/pages/drive/index.tsx | 3 ++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/components/Dropdowns/PodDropdown/PodDropdownToggle.tsx b/src/components/Dropdowns/PodDropdown/PodDropdownToggle.tsx index 9d7750d1..2c30dde3 100644 --- a/src/components/Dropdowns/PodDropdown/PodDropdownToggle.tsx +++ b/src/components/Dropdowns/PodDropdown/PodDropdownToggle.tsx @@ -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 = () => { @@ -36,6 +37,7 @@ const PodDropdownToggele = () => { /> )} { 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); @@ -55,6 +61,9 @@ const DriveSideBar: FC = () => { }; const handleOpenPod = (podName: string) => { + if (podLoading) { + return; + } setActivePod(podName); setDirectoryName('root'); }; diff --git a/src/context/PodContext.tsx b/src/context/PodContext.tsx index 65908695..a3da577b 100644 --- a/src/context/PodContext.tsx +++ b/src/context/PodContext.tsx @@ -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; @@ -20,6 +22,8 @@ interface PodContextProps { } const podContextDefaultValues: PodContext = { + loading: false, + setLoading: () => {}, pods: { pod_name: [], shared_pod_name: [] }, setPods: (pods: GetPodResponse) => {}, activePod: '', @@ -34,12 +38,14 @@ const podContextDefaultValues: PodContext = { const PodContext = createContext(podContextDefaultValues); const PodProvider: FC = ({ children }) => { + const [loading, setLoading] = useState(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([]); @@ -49,6 +55,8 @@ const PodProvider: FC = ({ children }) => { return ( { const { trackPageView } = useMatomo(); const { theme } = useContext(ThemeContext); const { + loading, + setLoading, pods, activePod, setActivePod, @@ -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(() => {