« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateAdditionalFilesList.js9
-rw-r--r--src/content/dependencies/generateAlbumAdditionalFilesList.js18
2 files changed, 14 insertions, 13 deletions
diff --git a/src/content/dependencies/generateAdditionalFilesList.js b/src/content/dependencies/generateAdditionalFilesList.js
index 56e6686c..f698f032 100644
--- a/src/content/dependencies/generateAdditionalFilesList.js
+++ b/src/content/dependencies/generateAdditionalFilesList.js
@@ -30,11 +30,10 @@ export default {
     'language',
   ],
 
-  data(additionalFiles, {fileSize = true} = {}) {
+  data(additionalFiles) {
     return {
       // Additional files are already a serializable format.
       additionalFiles,
-      showFileSizes: fileSize,
     };
   },
 
@@ -52,7 +51,7 @@ export default {
     html,
     language,
   }) {
-    if (!slots.fileSizes) {
+    if (!slots.fileLinks) {
       return html.blank();
     }
 
@@ -61,7 +60,7 @@ export default {
         .filter(([key, value]) => value)
         .map(([key]) => key));
 
-    if (filesWithLinks.size === 0) {
+    if (empty(filesWithLinks)) {
       return html.blank();
     }
 
@@ -91,7 +90,7 @@ export default {
           html.tag('ul',
             files.map(file =>
               html.tag('li',
-                (slots.fileSizes[file]
+                (slots.fileSizes?.[file]
                   ? language.$('releaseInfo.additionalFiles.file.withSize', {
                       file: slots.fileLinks[file],
                       size: language.formatFileSize(slots.fileSizes[file]),
diff --git a/src/content/dependencies/generateAlbumAdditionalFilesList.js b/src/content/dependencies/generateAlbumAdditionalFilesList.js
index 5fd4e05b..23f32bf5 100644
--- a/src/content/dependencies/generateAlbumAdditionalFilesList.js
+++ b/src/content/dependencies/generateAlbumAdditionalFilesList.js
@@ -6,23 +6,21 @@ export default {
 
   extraDependencies: [
     'getSizeOfAdditionalFile',
+    'html',
     'urls',
   ],
 
-  data(album, additionalFiles, {fileSize = true} = {}) {
+  data(album, additionalFiles) {
     return {
       albumDirectory: album.directory,
       fileLocations: additionalFiles.flatMap(({files}) => files),
-      showFileSizes: fileSize,
     };
   },
 
-  relations(relation, album, additionalFiles, {fileSize = true} = {}) {
+  relations(relation, album, additionalFiles) {
     return {
       additionalFilesList:
-        relation('generateAdditionalFilesList', additionalFiles, {
-          fileSize,
-        }),
+        relation('generateAdditionalFilesList', additionalFiles),
 
       additionalFileLinks:
         Object.fromEntries(
@@ -35,7 +33,11 @@ export default {
     };
   },
 
-  generate(data, relations, {
+  slots: {
+    showFileSizes: {type: 'boolean', default: true},
+  },
+
+  generate(data, relations, slots, {
     getSizeOfAdditionalFile,
     urls,
   }) {
@@ -45,7 +47,7 @@ export default {
         fileSizes:
           Object.fromEntries(data.fileLocations.map(file => [
             file,
-            (data.showFileSizes
+            (slots.showFileSizes
               ? getSizeOfAdditionalFile(
                   urls
                     .from('media.root')