Skip to content

Commit

Permalink
Merge pull request #532 from fairDataSociety/fix/325
Browse files Browse the repository at this point in the history
Fix: #325
  • Loading branch information
tomicvladan authored Oct 6, 2023
2 parents d095dd2 + 804f7d8 commit ab62e1d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/pages/drive/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<string | null>(null);

useEffect(() => {
trackPageView({
Expand All @@ -83,6 +89,7 @@ const Drive: FC = () => {
if (!activePod) {
return;
}
setError(null);

const userAddress = await getAccountAddress();
const directory = directoryName || 'root';
Expand Down Expand Up @@ -136,6 +143,8 @@ const Drive: FC = () => {
setFiles(null);
await handleFetchPods();
}
} else {
setError(errorToString(error));
}
} finally {
setLoading(false);
Expand All @@ -144,6 +153,7 @@ const Drive: FC = () => {

const handleFetchPods = async () => {
try {
setError(null);
setLoading(true);
const response = await getPods(fdpClientRef.current);
setPods(response);
Expand Down Expand Up @@ -181,6 +191,8 @@ const Drive: FC = () => {
return;
}

setError(null);

setLoading(true);

if (directoryName !== 'root') {
Expand All @@ -197,6 +209,8 @@ const Drive: FC = () => {
return;
}

setError(null);

setLoading(true);

setDirectoryName(newDirectory);
Expand All @@ -205,6 +219,7 @@ const Drive: FC = () => {
};

const handleFileOnClick = (data: FileItem) => {
setError(null);
setPreviewFile(data);
setShowPreviewModal(true);
};
Expand All @@ -214,11 +229,13 @@ const Drive: FC = () => {
};

const handlePodSelect = (pod: string) => {
setError(null);
setActivePod(pod);
setDirectoryName('root');
};

const onBackToDrive = () => {
setError(null);
setActivePod('');
setDirectoryName('');
};
Expand Down Expand Up @@ -269,6 +286,9 @@ const Drive: FC = () => {
</div>
) : null}
<Spinner isLoading={loading || !pods} />
<div className="mb-5 text-center">
<FeedbackMessage type="error" message={error} />
</div>

{!loading && (
<div style={{ marginTop: 15 }}>
Expand Down

0 comments on commit ab62e1d

Please sign in to comment.