Skip to content

Commit 4bfef6b

Browse files
committed
fix: if flatmap is empty
1 parent c118305 commit 4bfef6b

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

apps/frontend/src/components/media/new.uploader.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,10 @@ export function useUppyUploader(props: {
8888
// Expand generic types to specific ones
8989
const expandedTypes = allowedTypes.flatMap((type) => {
9090
if (type === 'image/*') {
91-
return [
92-
'image/png',
93-
'image/jpeg',
94-
'image/jpg',
95-
'image/gif',
96-
];
91+
return ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'];
9792
}
9893
if (type === 'video/*') {
99-
return [
100-
'video/mp4',
101-
'video/mpeg',
102-
];
94+
return ['video/mp4', 'video/mpeg'];
10395
}
10496
return [type];
10597
});
@@ -214,12 +206,11 @@ export function useUppyUploader(props: {
214206
return;
215207
}
216208

217-
console.log(result);
218209
if (transloadit.length > 0) {
219210
// @ts-ignore
220211
const allRes = result.transloadit[0].results;
221212
const toSave = uniq<string>(
222-
allRes[Object.keys(allRes)[0]].flatMap((item: any) =>
213+
(allRes[Object.keys(allRes)[0]] || []).flatMap((item: any) =>
223214
item.url.split('/').pop()
224215
)
225216
);

0 commit comments

Comments
 (0)