From 4bfef6badeb9c9fac55a023f3919ae73329ca268 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Thu, 4 Sep 2025 23:55:59 +0700 Subject: [PATCH] fix: if flatmap is empty --- .../src/components/media/new.uploader.tsx | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/apps/frontend/src/components/media/new.uploader.tsx b/apps/frontend/src/components/media/new.uploader.tsx index 850fdc84..febe58fe 100644 --- a/apps/frontend/src/components/media/new.uploader.tsx +++ b/apps/frontend/src/components/media/new.uploader.tsx @@ -88,18 +88,10 @@ export function useUppyUploader(props: { // Expand generic types to specific ones const expandedTypes = allowedTypes.flatMap((type) => { if (type === 'image/*') { - return [ - 'image/png', - 'image/jpeg', - 'image/jpg', - 'image/gif', - ]; + return ['image/png', 'image/jpeg', 'image/jpg', 'image/gif']; } if (type === 'video/*') { - return [ - 'video/mp4', - 'video/mpeg', - ]; + return ['video/mp4', 'video/mpeg']; } return [type]; }); @@ -214,12 +206,11 @@ export function useUppyUploader(props: { return; } - console.log(result); if (transloadit.length > 0) { // @ts-ignore const allRes = result.transloadit[0].results; const toSave = uniq( - allRes[Object.keys(allRes)[0]].flatMap((item: any) => + (allRes[Object.keys(allRes)[0]] || []).flatMap((item: any) => item.url.split('/').pop() ) );