« 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/things.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things.js')
-rw-r--r--src/data/things.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/data/things.js b/src/data/things.js
index ee458006..2037faca 100644
--- a/src/data/things.js
+++ b/src/data/things.js
@@ -718,6 +718,7 @@ Track.propertyDescriptors = {
   coverArtistContribsByRef: Thing.common.contribsByRef(),
 
   referencedTracksByRef: Thing.common.referenceList(Track),
+  sampledTracksByRef: Thing.common.referenceList(Track),
   artTagsByRef: Thing.common.referenceList(ArtTag),
 
   hasCoverArt: {
@@ -914,6 +915,12 @@ Track.propertyDescriptors = {
     find.track
   ),
 
+  sampledTracks: Thing.common.dynamicThingsFromReferenceList(
+    'sampledTracksByRef',
+    'trackData',
+    find.track
+  ),
+
   // Specifically exclude re-releases from this list - while it's useful to
   // get from a re-release to the tracks it references, re-releases aren't
   // generally relevant from the perspective of the tracks being referenced.
@@ -937,6 +944,22 @@ Track.propertyDescriptors = {
     },
   },
 
+  // For the same reasoning, exclude re-releases from sampled tracks too.
+  sampledByTracks: {
+    flags: {expose: true},
+
+    expose: {
+      dependencies: ['trackData'],
+
+      compute: ({trackData, [Track.instance]: track}) =>
+        trackData
+          ? trackData
+              .filter((t) => !t.originalReleaseTrack)
+              .filter((t) => t.sampledTracks?.includes(track))
+          : [],
+    },
+  },
+
   // Previously known as: (track).flashes
   featuredInFlashes: Thing.common.reverseReferenceList(
     'flashData',