Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: #325 #532

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading