« get me outta code hell

content: generate{Album,}AdditionalFilesList: syntax cleanup - 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>2024-04-02 11:34:59 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-04-02 11:34:59 -0300
commitc7064ecf5cc6f82b4519ae2bec3f219f07865a29 (patch)
tree46996cb55fe84e2e68c95de33256666d7bb2e468 /src
parentd7a98669e875005c70a3ce93755483fb67054725 (diff)
content: generate{Album,}AdditionalFilesList: syntax cleanup
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateAdditionalFilesList.js10
-rw-r--r--src/content/dependencies/generateAlbumAdditionalFilesList.js77
2 files changed, 37 insertions, 50 deletions
diff --git a/src/content/dependencies/generateAdditionalFilesList.js b/src/content/dependencies/generateAdditionalFilesList.js
index 92948c7a..fc24ee52 100644
--- a/src/content/dependencies/generateAdditionalFilesList.js
+++ b/src/content/dependencies/generateAdditionalFilesList.js
@@ -27,12 +27,10 @@ function validateFileMapping(v, validateValue) {
 export default {
   extraDependencies: ['html', 'language'],
 
-  data(additionalFiles) {
-    return {
-      // Additional files are already a serializable format.
-      additionalFiles,
-    };
-  },
+  data: (additionalFiles) => ({
+    // Additional files are already a serializable format.
+    additionalFiles,
+  }),
 
   slots: {
     fileLinks: {
diff --git a/src/content/dependencies/generateAlbumAdditionalFilesList.js b/src/content/dependencies/generateAlbumAdditionalFilesList.js
index 23f32bf5..06694c95 100644
--- a/src/content/dependencies/generateAlbumAdditionalFilesList.js
+++ b/src/content/dependencies/generateAlbumAdditionalFilesList.js
@@ -4,56 +4,45 @@ export default {
     'linkAlbumAdditionalFile',
   ],
 
-  extraDependencies: [
-    'getSizeOfAdditionalFile',
-    'html',
-    'urls',
-  ],
+  extraDependencies: ['getSizeOfAdditionalFile', 'html', 'urls'],
 
-  data(album, additionalFiles) {
-    return {
-      albumDirectory: album.directory,
-      fileLocations: additionalFiles.flatMap(({files}) => files),
-    };
-  },
+  data: (album, additionalFiles) => ({
+    albumDirectory: album.directory,
 
-  relations(relation, album, additionalFiles) {
-    return {
-      additionalFilesList:
-        relation('generateAdditionalFilesList', additionalFiles),
+    fileLocations:
+      additionalFiles.flatMap(({files}) => files),
+  }),
 
-      additionalFileLinks:
-        Object.fromEntries(
-          additionalFiles
-            .flatMap(({files}) => files)
-            .map(file => [
-              file,
-              relation('linkAlbumAdditionalFile', album, file),
-            ])),
-    };
-  },
+  relations: (relation, album, additionalFiles) => ({
+    additionalFilesList:
+      relation('generateAdditionalFilesList', additionalFiles),
+
+    additionalFileLinks:
+      Object.fromEntries(
+        additionalFiles
+          .flatMap(({files}) => files)
+          .map(file => [
+            file,
+            relation('linkAlbumAdditionalFile', album, file),
+          ])),
+  }),
 
   slots: {
     showFileSizes: {type: 'boolean', default: true},
   },
 
-  generate(data, relations, slots, {
-    getSizeOfAdditionalFile,
-    urls,
-  }) {
-    return relations.additionalFilesList
-      .slots({
-        fileLinks: relations.additionalFileLinks,
-        fileSizes:
-          Object.fromEntries(data.fileLocations.map(file => [
-            file,
-            (slots.showFileSizes
-              ? getSizeOfAdditionalFile(
-                  urls
-                    .from('media.root')
-                    .to('media.albumAdditionalFile', data.albumDirectory, file))
-              : 0),
-          ])),
-      });
-  },
+  generate: (data, relations, slots, {getSizeOfAdditionalFile, urls}) =>
+    relations.additionalFilesList.slots({
+      fileLinks: relations.additionalFileLinks,
+      fileSizes:
+        Object.fromEntries(data.fileLocations.map(file => [
+          file,
+          (slots.showFileSizes
+            ? getSizeOfAdditionalFile(
+                urls
+                  .from('media.root')
+                  .to('media.albumAdditionalFile', data.albumDirectory, file))
+            : 0),
+        ])),
+    }),
 };