« get me outta code hell

content: generateAlbumAdditionalFilesList: defend missing props - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-04-02 17:13:04 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-04-02 17:13:30 -0300
commit1503827fb835299e4893f0adbb780a277ea2cdde (patch)
treee797fe31fb5a3a6cc6d72fd18e3e22cd84a2a1eb
parent93e40175701d580452ef24b6cd6146dc4f3dfd43 (diff)
content: generateAlbumAdditionalFilesList: defend missing props
-rw-r--r--src/content/dependencies/generateAlbumAdditionalFilesList.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/content/dependencies/generateAlbumAdditionalFilesList.js b/src/content/dependencies/generateAlbumAdditionalFilesList.js
index 3ab0e27a..b9269d74 100644
--- a/src/content/dependencies/generateAlbumAdditionalFilesList.js
+++ b/src/content/dependencies/generateAlbumAdditionalFilesList.js
@@ -20,13 +20,15 @@ export default {
 
     chunkItems:
       additionalFiles
-        .map(({files}) => files
-          .map(() => relation('generateAdditionalFilesListChunkItem'))),
+        .map(({files}) =>
+          (files ?? [])
+            .map(() => relation('generateAdditionalFilesListChunkItem'))),
 
     chunkItemFileLinks:
       additionalFiles
-        .map(({files}) => files
-          .map(file => relation('linkAlbumAdditionalFile', album, file))),
+        .map(({files}) =>
+          (files ?? [])
+            .map(file => relation('linkAlbumAdditionalFile', album, file))),
   }),
 
   data: (album, additionalFiles) => ({
@@ -38,11 +40,11 @@ export default {
 
     chunkDescriptions:
       additionalFiles
-        .map(({description}) => description),
+        .map(({description}) => description ?? null),
 
     chunkItemLocations:
       additionalFiles
-        .map(({files}) => files),
+        .map(({files}) => files ?? []),
   }),
 
   slots: {