« get me outta code hell

data, content: always fallback coverArtDate to date - 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-03-31 15:02:27 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-04-10 16:02:35 -0300
commit02216898a5bf22359219b77eb48ba9928fa7ea94 (patch)
tree62b0dcc13e6b9316587d74cc4102fec62d7c1608 /src
parent0ee4a82115ae8d41260521ea9080bf0c7d455ab0 (diff)
data, content: always fallback coverArtDate to date
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateArtTagGalleryPage.js2
-rw-r--r--src/content/dependencies/generateArtistGalleryPage.js2
-rw-r--r--src/content/dependencies/generateTrackReleaseInfo.js1
-rw-r--r--src/content/dependencies/listArtistsByLatestContribution.js5
-rw-r--r--src/data/composite/things/track/withTrackArtDate.js24
-rw-r--r--src/data/composite/wiki-data/withCoverArtDate.js23
-rw-r--r--src/data/things/album.js18
-rw-r--r--src/data/things/art-tag.js2
-rw-r--r--src/data/things/track.js15
9 files changed, 23 insertions, 69 deletions
diff --git a/src/content/dependencies/generateArtTagGalleryPage.js b/src/content/dependencies/generateArtTagGalleryPage.js
index b633e58f..d51700d4 100644
--- a/src/content/dependencies/generateArtTagGalleryPage.js
+++ b/src/content/dependencies/generateArtTagGalleryPage.js
@@ -31,7 +31,7 @@ export default {
     const allThings = unique([...directThings, ...indirectThings]);
 
     sortAlbumsTracksChronologically(allThings, {
-      getDate: thing => thing.coverArtDate ?? thing.date,
+      getDate: thing => thing.coverArtDate,
       latestFirst: true,
     });
 
diff --git a/src/content/dependencies/generateArtistGalleryPage.js b/src/content/dependencies/generateArtistGalleryPage.js
index 7a76188a..38696c9c 100644
--- a/src/content/dependencies/generateArtistGalleryPage.js
+++ b/src/content/dependencies/generateArtistGalleryPage.js
@@ -24,7 +24,7 @@ export default {
 
     sortAlbumsTracksChronologically(things, {
       latestFirst: true,
-      getDate: thing => thing.coverArtDate ?? thing.date,
+      getDate: thing => thing.coverArtDate,
     });
 
     return {things};
diff --git a/src/content/dependencies/generateTrackReleaseInfo.js b/src/content/dependencies/generateTrackReleaseInfo.js
index 38b8383f..6f473041 100644
--- a/src/content/dependencies/generateTrackReleaseInfo.js
+++ b/src/content/dependencies/generateTrackReleaseInfo.js
@@ -37,7 +37,6 @@ export default {
 
     if (
       track.hasUniqueCoverArt &&
-      track.coverArtDate &&
       +track.coverArtDate !== +track.date
     ) {
       data.coverArtDate = track.coverArtDate;
diff --git a/src/content/dependencies/listArtistsByLatestContribution.js b/src/content/dependencies/listArtistsByLatestContribution.js
index 27a2faa3..2a8d1b4c 100644
--- a/src/content/dependencies/listArtistsByLatestContribution.js
+++ b/src/content/dependencies/listArtistsByLatestContribution.js
@@ -98,13 +98,16 @@ export default {
       ])) {
         // Might combine later with 'track' of the same album and date.
         considerDate(artist, album.coverArtDate ?? album.date, album, 'artwork');
+        // '?? album.date' is kept here because wallpaper and banner may
+        // technically be present for an album w/o cover art, therefore
+        // also no cover art date.
       }
     }
 
     for (const track of tracksLatestFirst) {
       for (const artist of getArtists(track, 'coverArtistContribs')) {
         // No special effect if artist already has 'artwork' for the same album and date.
-        considerDate(artist, track.coverArtDate ?? track.date, track.album, 'artwork');
+        considerDate(artist, track.coverArtDate, track.album, 'artwork');
       }
 
       for (const artist of new Set([
diff --git a/src/data/composite/things/track/withTrackArtDate.js b/src/data/composite/things/track/withTrackArtDate.js
index e2c4d8bc..9b7b61c7 100644
--- a/src/data/composite/things/track/withTrackArtDate.js
+++ b/src/data/composite/things/track/withTrackArtDate.js
@@ -1,11 +1,3 @@
-// Gets the date of cover art release. This represents only the track's own
-// unique cover artwork, if any.
-//
-// If the 'fallback' option is false (the default), this will only output
-// the track's own coverArtDate or its album's trackArtDate. If 'fallback'
-// is set, and neither of these is available, it'll output the track's own
-// date instead.
-
 import {input, templateCompositeFrom} from '#composite';
 import {isDate} from '#validators';
 
@@ -24,11 +16,6 @@ export default templateCompositeFrom({
       defaultDependency: 'coverArtDate',
       acceptsNull: true,
     }),
-
-    fallback: input({
-      type: 'boolean',
-      defaultValue: false,
-    }),
   },
 
   outputs: ['#trackArtDate'],
@@ -57,20 +44,13 @@ export default templateCompositeFrom({
     }),
 
     {
-      dependencies: [
-        '#album.trackArtDate',
-        input('fallback'),
-      ],
-
+      dependencies: ['#album.trackArtDate'],
       compute: (continuation, {
         ['#album.trackArtDate']: albumTrackArtDate,
-        [input('fallback')]: fallback,
       }) =>
         (albumTrackArtDate
           ? continuation.raiseOutput({'#trackArtDate': albumTrackArtDate})
-       : fallback
-          ? continuation()
-          : continuation.raiseOutput({'#trackArtDate': null})),
+          : continuation()),
     },
 
     withDate().outputs({
diff --git a/src/data/composite/wiki-data/withCoverArtDate.js b/src/data/composite/wiki-data/withCoverArtDate.js
index 0c644c77..a114d5ff 100644
--- a/src/data/composite/wiki-data/withCoverArtDate.js
+++ b/src/data/composite/wiki-data/withCoverArtDate.js
@@ -1,7 +1,3 @@
-// Gets the current thing's coverArtDate, or, if the 'fallback' option is set,
-// the thing's date. This is always null if the thing doesn't actually have
-// any coverArtistContribs.
-
 import {input, templateCompositeFrom} from '#composite';
 import {isDate} from '#validators';
 
@@ -18,11 +14,6 @@ export default templateCompositeFrom({
       defaultDependency: 'coverArtDate',
       acceptsNull: true,
     }),
-
-    fallback: input({
-      type: 'boolean',
-      defaultValue: false,
-    }),
   },
 
   outputs: ['#coverArtDate'],
@@ -50,21 +41,11 @@ export default templateCompositeFrom({
     },
 
     {
-      dependencies: [input('fallback')],
-      compute: (continuation, {
-        [input('fallback')]: fallback,
-      }) =>
-        (fallback
-          ? continuation()
-          : continuation.raiseOutput({'#coverArtDate': null})),
-    },
-
-    {
       dependencies: ['date'],
       compute: (continuation, {date}) =>
         (date
-          ? continuation.raiseOutput({'#coverArtDate': date})
-          : continuation.raiseOutput({'#coverArtDate': null})),
+          ? continuation({'#coverArtDate': date})
+          : continuation({'#coverArtDate': null})),
     },
   ],
 });
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 5aba75f7..e7ab9def 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -104,16 +104,10 @@ export class Album extends Thing {
     dateAddedToWiki: simpleDate(),
 
     coverArtDate: [
-      // ~~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,
         }),
-
-        fallback: input.value(true),
       }),
 
       exposeDependency({dependency: '#coverArtDate'}),
@@ -181,9 +175,7 @@ export class Album extends Thing {
     }),
 
     coverArtistContribs: [
-      withCoverArtDate({
-        fallback: input.value(true),
-      }),
+      withCoverArtDate(),
 
       contributionList({
         date: '#coverArtDate',
@@ -202,9 +194,7 @@ export class Album extends Thing {
     }),
 
     wallpaperArtistContribs: [
-      withCoverArtDate({
-        fallback: input.value(true),
-      }),
+      withCoverArtDate(),
 
       contributionList({
         date: '#coverArtDate',
@@ -213,9 +203,7 @@ export class Album extends Thing {
     ],
 
     bannerArtistContribs: [
-      withCoverArtDate({
-        fallback: input.value(true),
-      }),
+      withCoverArtDate(),
 
       contributionList({
         date: '#coverArtDate',
diff --git a/src/data/things/art-tag.js b/src/data/things/art-tag.js
index c88fcdc2..886a256c 100644
--- a/src/data/things/art-tag.js
+++ b/src/data/things/art-tag.js
@@ -105,7 +105,7 @@ export class ArtTag extends Thing {
               ...reverse.albumsWhoseArtworksFeature(artTag),
               ...reverse.tracksWhoseArtworksFeature(artTag),
             ],
-            {getDate: thing => thing.coverArtDate ?? thing.date}),
+            {getDate: thing => thing.coverArtDate}),
       },
     },
 
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 69953d33..afb2197d 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -283,9 +283,7 @@ export class Track extends Thing {
         value: input.value([]),
       }),
 
-      withTrackArtDate({
-        fallback: input.value(true),
-      }),
+      withTrackArtDate(),
 
       withResolvedContribs({
         from: input.updateValue({validate: isContributionList}),
@@ -340,6 +338,13 @@ export class Track extends Thing {
       }),
     ],
 
+    trackArtwork: [
+      constitutibleArtwork({
+        contribs: 'coverArtistContribs',
+        date: 'coverArtDate',
+      }),
+    ],
+
     artTags: [
       exitWithoutUniqueCoverArt({
         value: input.value([]),
@@ -356,9 +361,7 @@ export class Track extends Thing {
         value: input.value([]),
       }),
 
-      withTrackArtDate({
-        fallback: input.value(true),
-      }),
+      withTrackArtDate(),
 
       referencedArtworkList({
         date: '#trackArtDate',