From 57217e90a3736c43bce21e898e75d300cef11261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladan=20Tomi=C4=87?= Date: Mon, 2 Oct 2023 18:18:17 +0200 Subject: [PATCH] fix: drive error (#325) --- src/pages/drive/index.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/pages/drive/index.tsx b/src/pages/drive/index.tsx index 0e35b318..6d2a7387 100644 --- a/src/pages/drive/index.tsx +++ b/src/pages/drive/index.tsx @@ -34,8 +34,13 @@ import { } from '@utils/cache'; import { RefreshDriveOptions } from '@interfaces/handlers'; import DirectoryPath from '@components/DirectoryPath/DirectoryPath'; -import { isDataNotFoundError, isJsonParsingError } from '@utils/error'; +import { + errorToString, + isDataNotFoundError, + isJsonParsingError, +} from '@utils/error'; import PodList from '@components/Views/PodList/PodList'; +import FeedbackMessage from '@components/FeedbackMessage/FeedbackMessage'; const Drive: FC = () => { const { trackPageView } = useMatomo(); @@ -62,6 +67,7 @@ const Drive: FC = () => { const [driveSort, setDriveSort] = useState('a-z'); const [loading, setLoading] = useState(false); const { fdpClientRef, getAccountAddress } = useFdpStorage(); + const [error, setError] = useState(null); useEffect(() => { trackPageView({ @@ -83,6 +89,7 @@ const Drive: FC = () => { if (!activePod) { return; } + setError(null); const userAddress = await getAccountAddress(); const directory = directoryName || 'root'; @@ -136,6 +143,8 @@ const Drive: FC = () => { setFiles(null); await handleFetchPods(); } + } else { + setError(errorToString(error)); } } finally { setLoading(false); @@ -144,6 +153,7 @@ const Drive: FC = () => { const handleFetchPods = async () => { try { + setError(null); setLoading(true); const response = await getPods(fdpClientRef.current); setPods(response); @@ -181,6 +191,8 @@ const Drive: FC = () => { return; } + setError(null); + setLoading(true); if (directoryName !== 'root') { @@ -197,6 +209,8 @@ const Drive: FC = () => { return; } + setError(null); + setLoading(true); setDirectoryName(newDirectory); @@ -205,6 +219,7 @@ const Drive: FC = () => { }; const handleFileOnClick = (data: FileItem) => { + setError(null); setPreviewFile(data); setShowPreviewModal(true); }; @@ -214,11 +229,13 @@ const Drive: FC = () => { }; const handlePodSelect = (pod: string) => { + setError(null); setActivePod(pod); setDirectoryName('root'); }; const onBackToDrive = () => { + setError(null); setActivePod(''); setDirectoryName(''); }; @@ -269,6 +286,9 @@ const Drive: FC = () => { ) : null} +
+ +
{!loading && (activePod ? (