« get me outta code hell

data: with{Resolved,Reverse}AnnotatedReferenceList: dates - 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>2025-01-03 08:11:15 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-01-03 08:11:15 -0400
commita2488d2f5f5d1b9ef096c2d9968c56e6439adcac (patch)
tree2bb65015f29e3c3b76a58e5c80ced9bed1ca3a68 /src
parentc6687d47da7d5e065b75b2ae22deb4671dd1671b (diff)
data: with{Resolved,Reverse}AnnotatedReferenceList: dates
Diffstat (limited to 'src')
-rw-r--r--src/data/composite/wiki-data/withResolvedAnnotatedReferenceList.js18
-rw-r--r--src/data/composite/wiki-data/withReverseAnnotatedReferenceList.js10
-rw-r--r--src/data/composite/wiki-properties/annotatedReferenceList.js8
-rw-r--r--src/data/composite/wiki-properties/referencedArtworkList.js9
-rw-r--r--src/data/things/album.js20
-rw-r--r--src/data/things/group.js2
-rw-r--r--src/data/things/track.js8
7 files changed, 71 insertions, 4 deletions
diff --git a/src/data/composite/wiki-data/withResolvedAnnotatedReferenceList.js b/src/data/composite/wiki-data/withResolvedAnnotatedReferenceList.js
index e2b8a0a1..789a8844 100644
--- a/src/data/composite/wiki-data/withResolvedAnnotatedReferenceList.js
+++ b/src/data/composite/wiki-data/withResolvedAnnotatedReferenceList.js
@@ -1,6 +1,6 @@
 import {input, templateCompositeFrom} from '#composite';
 import {stitchArrays} from '#sugar';
-import {isObject, validateArrayItems} from '#validators';
+import {isDate, isObject, validateArrayItems} from '#validators';
 
 import {withPropertyFromList} from '#composite/data';
 
@@ -24,6 +24,11 @@ export default templateCompositeFrom({
       acceptsNull: true,
     }),
 
+    date: input({
+      validate: isDate,
+      acceptsNull: true,
+    }),
+
     reference: input({type: 'string', defaultValue: 'reference'}),
     annotation: input({type: 'string', defaultValue: 'annotation'}),
     thing: input({type: 'string', defaultValue: 'thing'}),
@@ -93,6 +98,17 @@ export default templateCompositeFrom({
       }),
     },
 
+    {
+      dependencies: ['#matches', input('date')],
+      compute: (continuation, {
+        ['#matches']: matches,
+        [input('date')]: date,
+      }) => continuation({
+        ['#matches']:
+          matches.map(match => ({...match, date})),
+      }),
+    },
+
     withAvailabilityFilter({
       from: '#resolvedReferenceList',
     }),
diff --git a/src/data/composite/wiki-data/withReverseAnnotatedReferenceList.js b/src/data/composite/wiki-data/withReverseAnnotatedReferenceList.js
index debc68e4..feae9ccb 100644
--- a/src/data/composite/wiki-data/withReverseAnnotatedReferenceList.js
+++ b/src/data/composite/wiki-data/withReverseAnnotatedReferenceList.js
@@ -67,12 +67,20 @@ export default withReverseList_template({
       '#values': '#annotations',
     }),
 
+    withPropertyFromList({
+      list: '#references',
+      property: input.value('date'),
+    }).outputs({
+      '#references.date': '#dates',
+    }),
+
     {
       dependencies: [
         input('backward'),
         input('annotation'),
         '#things',
         '#annotations',
+        '#dates',
       ],
 
       compute: (continuation, {
@@ -80,11 +88,13 @@ export default withReverseList_template({
         [input('annotation')]: annotationProperty,
         ['#things']: things,
         ['#annotations']: annotations,
+        ['#dates']: dates,
       }) => continuation({
         '#referencingThings':
           stitchArrays({
             [thingProperty]: things,
             [annotationProperty]: annotations,
+            date: dates,
           }),
       }),
     },
diff --git a/src/data/composite/wiki-properties/annotatedReferenceList.js b/src/data/composite/wiki-properties/annotatedReferenceList.js
index 860f3c3d..d6364475 100644
--- a/src/data/composite/wiki-properties/annotatedReferenceList.js
+++ b/src/data/composite/wiki-properties/annotatedReferenceList.js
@@ -4,6 +4,7 @@ import {combineWikiDataArrays} from '#wiki-data';
 
 import {
   isContentString,
+  isDate,
   optional,
   validateArrayItems,
   validateProperties,
@@ -28,6 +29,11 @@ export default templateCompositeFrom({
     data: inputWikiData({allowMixedTypes: true}),
     find: input({type: 'function'}),
 
+    date: input({
+      validate: isDate,
+      acceptsNull: true,
+    }),
+
     reference: input.staticValue({type: 'string', defaultValue: 'reference'}),
     annotation: input.staticValue({type: 'string', defaultValue: 'annotation'}),
     thing: input.staticValue({type: 'string', defaultValue: 'thing'}),
@@ -53,6 +59,8 @@ export default templateCompositeFrom({
     withResolvedAnnotatedReferenceList({
       list: input.updateValue(),
 
+      date: input('date'),
+
       reference: input('reference'),
       annotation: input('annotation'),
       thing: input('thing'),
diff --git a/src/data/composite/wiki-properties/referencedArtworkList.js b/src/data/composite/wiki-properties/referencedArtworkList.js
index a242af2c..819b2f43 100644
--- a/src/data/composite/wiki-properties/referencedArtworkList.js
+++ b/src/data/composite/wiki-properties/referencedArtworkList.js
@@ -1,5 +1,6 @@
 import {input, templateCompositeFrom} from '#composite';
 import find from '#find';
+import {isDate} from '#validators';
 import {combineWikiDataArrays} from '#wiki-data';
 
 import annotatedReferenceList from './annotatedReferenceList.js';
@@ -9,6 +10,13 @@ export default templateCompositeFrom({
 
   compose: false,
 
+  inputs: {
+    date: input({
+      validate: isDate,
+      acceptsNull: true,
+    }),
+  },
+
   steps: () => [
     {
       dependencies: [
@@ -42,6 +50,7 @@ export default templateCompositeFrom({
       referenceType: input.value(['album', 'track']),
       data: '#data',
       find: '#find',
+      date: input('date'),
     }),
   ],
 });
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 303c64b6..af3c6a92 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -106,7 +106,10 @@ export class Album extends Thing {
     dateAddedToWiki: simpleDate(),
 
     coverArtDate: [
-      // TODO: Why does this fall back, but Track.coverArtDate doesn't?
+      // ~~TODO: Why does this fall back, but Track.coverArtDate doesn't?~~
+      // TODO: OK so it's because tracks don't *store* dates just like that.
+      // Really instead of fallback being a flag, it should be a date value,
+      // if this option is worth existing at all.
       withCoverArtDate({
         from: input.updateValue({
           validate: isDate,
@@ -242,7 +245,20 @@ export class Album extends Thing {
         value: input.value([]),
       }),
 
-      referencedArtworkList(),
+      {
+        dependencies: ['coverArtDate', 'date'],
+        compute: (continuation, {
+          coverArtDate,
+          date,
+        }) => continuation({
+          ['#date']:
+            coverArtDate ?? date,
+        }),
+      },
+
+      referencedArtworkList({
+        date: '#date',
+      }),
     ],
 
     // Update only
diff --git a/src/data/things/group.js b/src/data/things/group.js
index 68f7545d..8418cb99 100644
--- a/src/data/things/group.js
+++ b/src/data/things/group.js
@@ -35,6 +35,8 @@ export class Group extends Thing {
       find: input.value(find.artist),
       data: 'artistData',
 
+      date: input.value(null),
+
       reference: input.value('artist'),
       thing: input.value('artist'),
     }),
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 7934daa6..a0d2f641 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -365,7 +365,13 @@ export class Track extends Thing {
         value: input.value([]),
       }),
 
-      referencedArtworkList(),
+      withTrackArtDate({
+        fallback: input.value(true),
+      }),
+
+      referencedArtworkList({
+        date: '#trackArtDate',
+      }),
     ],
 
     // Update only