« get me outta code hell

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:
Diffstat (limited to 'src/data')
-rw-r--r--src/data/checks.js19
-rw-r--r--src/data/composite/things/track/withMainReleaseTrack.js14
-rw-r--r--src/data/composite/things/track/withPropertyFromMainRelease.js2
3 files changed, 29 insertions, 6 deletions
diff --git a/src/data/checks.js b/src/data/checks.js
index fb4a9673..de433de4 100644
--- a/src/data/checks.js
+++ b/src/data/checks.js
@@ -405,11 +405,20 @@ export function filterReferenceErrors(wikiData, {
                     // gets refactored, there might be trouble here...
 
                     if (thing.mainReleaseTrack === null) {
-                      throw new Error(
-                        `Matched album for reference "${ref}":\n` +
-                        `- ` + inspect(album) + `\n` +
-                        `...but none of its tracks automatically match this secondary release.\n` +
-                        `Please resolve by specifying the track here, instead of the album.`);
+                      if (album === thing.album) {
+                        throw new Error(
+                          `Matched album for reference "${ref}":\n` +
+                          `- ` + inspect(album) + `\n` +
+                          `...but this is the album that includes this secondary release, itself.\n` +
+                          `Please resolve by pointing to aonther album here, or by removing this\n` +
+                          `Main Release field, if this track is meant to be the main release.`);
+                      } else {
+                        throw new Error(
+                          `Matched album for reference "${ref}":\n` +
+                          `- ` + inspect(album) + `\n` +
+                          `...but none of its tracks automatically match this secondary release.\n` +
+                          `Please resolve by specifying the track here, instead of the album.`);
+                      }
                     } else {
                       return album;
                     }
diff --git a/src/data/composite/things/track/withMainReleaseTrack.js b/src/data/composite/things/track/withMainReleaseTrack.js
index 871eba7d..e498582d 100644
--- a/src/data/composite/things/track/withMainReleaseTrack.js
+++ b/src/data/composite/things/track/withMainReleaseTrack.js
@@ -203,5 +203,19 @@ export default templateCompositeFrom({
           null,
       }),
     },
+
+    {
+      dependencies: ['#mainReleaseTrack', input.myself()],
+
+      compute: (continuation, {
+        ['#mainReleaseTrack']: mainReleaseTrack,
+        [input.myself()]: thisTrack,
+      }) => continuation({
+        ['#mainReleaseTrack']:
+          (mainReleaseTrack === thisTrack
+            ? null
+            : mainReleaseTrack),
+      }),
+    },
   ],
 });
diff --git a/src/data/composite/things/track/withPropertyFromMainRelease.js b/src/data/composite/things/track/withPropertyFromMainRelease.js
index 3e1b6d19..c6f65653 100644
--- a/src/data/composite/things/track/withPropertyFromMainRelease.js
+++ b/src/data/composite/things/track/withPropertyFromMainRelease.js
@@ -13,7 +13,7 @@ import {withPropertyFromObject} from '#composite/data';
 import withMainReleaseTrack from './withMainReleaseTrack.js';
 
 export default templateCompositeFrom({
-  annotation: `inheritFromMainRelease`,
+  annotation: `withPropertyFromMainRelease`,
 
   inputs: {
     property: input({type: 'string'}),