« get me outta code hell

data: withCoverArtDate refactor, make Album.coverArtDate updatable - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-03-07 12:27:34 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-06-12 17:26:44 -0300
commit7318aa7dbab75ef53ad2eb5e9d256fd21efdbd7b (patch)
tree22906882a7455aad0d1b9742cea98bad3ac3b748 /src/data/composite
parent1cf56b3364896cd0939b85b8b2fcb51155f9b69e (diff)
data: withCoverArtDate refactor, make Album.coverArtDate updatable
Diffstat (limited to 'src/data/composite')
-rw-r--r--src/data/composite/wiki-data/withCoverArtDate.js24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/data/composite/wiki-data/withCoverArtDate.js b/src/data/composite/wiki-data/withCoverArtDate.js
index 7c16ce0f..0c644c77 100644
--- a/src/data/composite/wiki-data/withCoverArtDate.js
+++ b/src/data/composite/wiki-data/withCoverArtDate.js
@@ -3,6 +3,7 @@
 // any coverArtistContribs.
 
 import {input, templateCompositeFrom} from '#composite';
+import {isDate} from '#validators';
 
 import {raiseOutputWithoutDependency} from '#composite/control-flow';
 
@@ -12,6 +13,12 @@ export default templateCompositeFrom({
   annotation: `withCoverArtDate`,
 
   inputs: {
+    from: input({
+      validate: isDate,
+      defaultDependency: 'coverArtDate',
+      acceptsNull: true,
+    }),
+
     fallback: input({
       type: 'boolean',
       defaultValue: false,
@@ -33,14 +40,21 @@ export default templateCompositeFrom({
     }),
 
     {
-      dependencies: ['coverArtDate', input('fallback')],
+      dependencies: [input('from')],
+      compute: (continuation, {
+        [input('from')]: from,
+      }) =>
+        (from
+          ? continuation.raiseOutput({'#coverArtDate': from})
+          : continuation()),
+    },
+
+    {
+      dependencies: [input('fallback')],
       compute: (continuation, {
-        ['coverArtDate']: coverArtDate,
         [input('fallback')]: fallback,
       }) =>
-        (coverArtDate
-          ? continuation.raiseOutput({'#coverArtDate': coverArtDate})
-       : fallback
+        (fallback
           ? continuation()
           : continuation.raiseOutput({'#coverArtDate': null})),
     },