« get me outta code hell

content: listAllAdditionalFilesTemplate: handle empty files - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-04-08 11:44:10 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-04-08 11:44:10 -0300
commitad349c3a6949d8e6751ada62f297038336b1bcc6 (patch)
treee862834a36e801186cc586528b6aa86c52009e67 /src/content/dependencies
parentab873b3b0594ca7424d22cbc7094e15ff33252e2 (diff)
content: listAllAdditionalFilesTemplate: handle empty files
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateListAllAdditionalFilesChunk.js6
-rw-r--r--src/content/dependencies/listAllAdditionalFilesTemplate.js4
2 files changed, 8 insertions, 2 deletions
diff --git a/src/content/dependencies/generateListAllAdditionalFilesChunk.js b/src/content/dependencies/generateListAllAdditionalFilesChunk.js
index b046ccaf..43a78cb3 100644
--- a/src/content/dependencies/generateListAllAdditionalFilesChunk.js
+++ b/src/content/dependencies/generateListAllAdditionalFilesChunk.js
@@ -51,6 +51,12 @@ export default {
                         }),
                     }))
 
+             : additionalFileLinks.length === 0
+                ? html.tag('li',
+                    language.$('listingPage', slots.stringsKey, 'file.withNoFiles', {
+                      title: additionalFileTitle,
+                    }))
+
                 : html.tag('li', {class: 'has-details'},
                     html.tag('details', [
                       html.tag('summary',
diff --git a/src/content/dependencies/listAllAdditionalFilesTemplate.js b/src/content/dependencies/listAllAdditionalFilesTemplate.js
index bf48c966..e33ad7b5 100644
--- a/src/content/dependencies/listAllAdditionalFilesTemplate.js
+++ b/src/content/dependencies/listAllAdditionalFilesTemplate.js
@@ -63,7 +63,7 @@ export default {
     const albumAdditionalFileFiles =
       albumAdditionalFileObjects
         .map(byAlbum => byAlbum
-          .map(({files}) => files));
+          .map(({files}) => files ?? []));
 
     const trackAdditionalFileTitles =
       trackAdditionalFileObjects
@@ -75,7 +75,7 @@ export default {
       trackAdditionalFileObjects
         .map(byAlbum => byAlbum
           .map(byTrack => byTrack
-            .map(({files}) => files)));
+            .map(({files}) => files ?? [])));
 
     return {
       spec,