From b42c3af05258b8e96daf28fbf945f3fcfe71590e Mon Sep 17 00:00:00 2001 From: Ben Merckx Date: Wed, 25 Oct 2023 10:58:12 +0200 Subject: [PATCH] Fix file uploader after merge ... --- src/dashboard/view/media/FileUploader.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/dashboard/view/media/FileUploader.tsx b/src/dashboard/view/media/FileUploader.tsx index ab2911a24..ebbd820c4 100644 --- a/src/dashboard/view/media/FileUploader.tsx +++ b/src/dashboard/view/media/FileUploader.tsx @@ -15,7 +15,7 @@ import css from './FileUploader.module.scss' const styles = fromModule(css) export interface FileUploaderProps { - destination: UploadDestination + destination?: UploadDestination max?: number toggleSelect?: (id: Entry) => void position?: 'left' | 'right' @@ -27,6 +27,7 @@ export function FileUploader({ toggleSelect, position = 'right' }: FileUploaderProps) { + const readOnly = !destination const {upload, uploads} = useUploads(toggleSelect) const [isOver, setIsOver] = useState(false) const isUploading = uploads.length > 0 @@ -37,7 +38,8 @@ export function FileUploader({ const todo = uploads.length - uploadsDone const [showUploads, setShowUploads] = useState(true) function uploadFiles(files: FileList) { - return upload(files, destination) + if (readOnly) return + return upload([...files], destination) } function handleFileInput(event: ChangeEvent) { const {files} = event.target @@ -88,12 +90,14 @@ export function FileUploader({