« get me outta code hell

yaml: warn for art tags specified on things without cover art - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-13 14:31:14 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-13 14:31:14 -0400
commite73b5f1739d2c9f54c66b25500dc80e9bef25f36 (patch)
tree52dceac1cbe3e2e71e9cb05344a8e3d00ea851f7 /src/data
parentba94f5c02f867630604f94eb64138fe260c320c1 (diff)
yaml: warn for art tags specified on things without cover art
Diffstat (limited to 'src/data')
-rw-r--r--src/data/yaml.js39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 9ee1d61..2137f99 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -1708,7 +1708,7 @@ export function filterReferenceErrors(wikiData) {
       wallpaperArtistContribs: '_contrib',
       bannerArtistContribs: '_contrib',
       groups: 'group',
-      artTags: 'artTag',
+      artTags: '_artTag',
       commentary: '_commentary',
     }],
 
@@ -1736,7 +1736,7 @@ export function filterReferenceErrors(wikiData) {
       coverArtistContribs: '_contrib',
       referencedTracks: '_trackNotRerelease',
       sampledTracks: '_trackNotRerelease',
-      artTags: 'artTag',
+      artTags: '_artTag',
       originalReleaseTrack: '_trackNotRerelease',
       commentary: '_commentary',
     }],
@@ -1814,6 +1814,10 @@ export function filterReferenceErrors(wikiData) {
             };
 
             switch (findFnKey) {
+              case '_artTag':
+                findFn = boundFind.artTag;
+                break;
+
               case '_commentary':
                 findFn = findArtistOrAlias;
                 break;
@@ -1903,6 +1907,37 @@ export function filterReferenceErrors(wikiData) {
             let newPropertyValue = value;
 
             determineNewPropertyValue: {
+              // TODO: The special-casing for artTag is obviously a bit janky.
+              // It would be nice if this could be moved to processDocument ala
+              // fieldCombinationErrors, but art tags are only an error if the
+              // thing doesn't have an artwork - which can't be determined from
+              // the track document on its own, thanks to inheriting contribs
+              // from the album.
+              if (findFnKey === '_artTag') {
+                let hasCoverArtwork =
+                  !empty(CacheableObject.getUpdateValue(thing, 'coverArtistContribs'));
+
+                if (processDocumentFn === processTrackDocument) {
+                  if (thing.album) {
+                    hasCoverArtwork ||=
+                      !empty(CacheableObject.getUpdateValue(thing.album, 'trackCoverArtistContribs'));
+                  }
+
+                  if (thing.disableUniqueCoverArt) {
+                    hasCoverArtwork = false;
+                  }
+                }
+
+                if (!hasCoverArtwork) {
+                  nest({message: errorMessage}, ({push}) => {
+                    push(new TypeError(`No cover artwork, so this shouldn't have art tags specified`));
+                  });
+
+                  newPropertyValue = [];
+                  break determineNewPropertyValue;
+                }
+              }
+
               if (findFnKey === '_commentary') {
                 filter(
                   value, {message: errorMessage},