« get me outta code hell

content: generateAdditionalFilesList: remove redundant fileSize opt - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-12 16:40:17 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-12 16:43:51 -0300
commit45895eee6b93a40f433a442d13829d1339f82801 (patch)
tree67e51cdfce79716ed2e1d50ada47cb30dc8aff71 /src
parent535acb34613b5cf7e22654619f4337b94b70644d (diff)
content: generateAdditionalFilesList: remove redundant fileSize opt
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')