fix: folder issues

This commit is contained in:
diced
2026-02-05 15:59:35 -08:00
parent 4656599bb0
commit e910fe9da5
2 changed files with 18 additions and 5 deletions
+15 -4
View File
@@ -8,7 +8,7 @@ import { Anchor, Breadcrumbs, Button, Group, Modal, Stack, Switch, TextInput, Ti
import { useForm } from '@mantine/form';
import { notifications } from '@mantine/notifications';
import { IconFolderPlus, IconHome, IconPlus } from '@tabler/icons-react';
import { useCallback, useMemo, useState } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import useSWR, { mutate } from 'swr';
import FolderGridView from './views/FolderGridView';
@@ -29,9 +29,11 @@ export default function DashboardFolders() {
const currentFolderId = folderPath.length > 0 ? folderPath[folderPath.length - 1] : null;
const { data: currentFolder } = useSWR<Folder>(
currentFolderId ? `/api/user/folders/${currentFolderId}` : null,
);
const {
data: currentFolder,
error: currentFolderError,
isLoading,
} = useSWR<Folder>(currentFolderId ? `/api/user/folders/${currentFolderId}` : null);
const form = useForm({
initialValues: {
@@ -106,6 +108,15 @@ export default function DashboardFolders() {
const breadcrumbs = buildBreadcrumbs();
useEffect(() => {
if (!currentFolderId) return;
if (isLoading) return;
if (currentFolderError || !currentFolder) {
navigate('/dashboard/folders', { replace: true });
}
}, [currentFolderId, currentFolder, currentFolderError, isLoading]);
return (
<>
<Modal
@@ -108,7 +108,9 @@ export default typedPlugin(
const fileCount = await addFolderToZip(zip, folderTree, '', logger);
if (fileCount === 0) {
logger.warn('folder export has no files', { folder: folder.id });
logger.warn('folder export has no files, aborting.', { folder: folder.id });
zip.abort();
}
zip.on('error', (err) => {