« get me outta code hell

Merge remote-tracking branch 'origin/staging' into data-steps - 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>2023-06-04 12:51:20 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-04 12:51:20 -0300
commit3096df0c06a750fc5a09e3bde93c7e524ee2b310 (patch)
tree669259f0261a682259564de22250df3763a423d8 /src/data
parent504b464f0904f0e008ee6e886e25c6778a99d479 (diff)
parent7830c73e6047ab8ec1322c4a56ed6a450bfb11e6 (diff)
Merge remote-tracking branch 'origin/staging' into data-steps
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/thing.js26
-rw-r--r--src/data/things/track.js2
-rw-r--r--src/data/yaml.js2
3 files changed, 25 insertions, 5 deletions
diff --git a/src/data/things/thing.js b/src/data/things/thing.js
index b74f45f5..5004f4e6 100644
--- a/src/data/things/thing.js
+++ b/src/data/things/thing.js
@@ -264,26 +264,42 @@ export default class Thing extends CacheableObject {
     // Dynamically inherit a contribution list from some other object, if it
     // hasn't been overridden on this object. This is handy for solo albums
     // where all tracks have the same artist, for example.
-    //
-    // Note: The arguments of this function aren't currently final! The final
-    // format will look more like (contribsByRef, parentContribsByRef), e.g.
-    // ('artistContribsByRef', '@album/artistContribsByRef').
     dynamicInheritContribs: (
+      // If this property is explicitly false, the contribution list returned
+      // will always be empty.
+      nullerProperty,
+
+      // Property holding contributions on the current object.
       contribsByRefProperty,
+
+      // Property holding corresponding "default" contributions on the parent
+      // object, which will fallen back to if the object doesn't have its own
+      // contribs.
       parentContribsByRefProperty,
+
+      // Data array to search in and "find" function to locate parent object
+      // (which will be passed the child object and the wiki data array).
       thingDataProperty,
       findFn
     ) => ({
       flags: {expose: true},
       expose: {
-        dependencies: [contribsByRefProperty, thingDataProperty, 'artistData'],
+        dependencies: [
+          contribsByRefProperty,
+          thingDataProperty,
+          nullerProperty,
+          'artistData',
+        ].filter(Boolean),
+
         compute({
           [Thing.instance]: thing,
+          [nullerProperty]: nuller,
           [contribsByRefProperty]: contribsByRef,
           [thingDataProperty]: thingData,
           artistData,
         }) {
           if (!artistData) return [];
+          if (nuller === false) return [];
           const refs =
             contribsByRef ??
             findFn(thing, thingData, {mode: 'quiet'})?.[parentContribsByRefProperty];
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 1c2013a2..00585c1e 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -245,6 +245,7 @@ export class Track extends Thing {
     },
 
     artistContribs: Thing.common.dynamicInheritContribs(
+      null,
       'artistContribsByRef',
       'artistContribsByRef',
       'albumData',
@@ -254,6 +255,7 @@ export class Track extends Thing {
     contributorContribs: Thing.common.dynamicContribs('contributorContribsByRef'),
 
     coverArtistContribs: Thing.common.dynamicInheritContribs(
+      'hasCoverArt',
       'coverArtistContribsByRef',
       'trackCoverArtistContribsByRef',
       'albumData',
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 5a6f2031..73450f17 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -24,6 +24,7 @@ import {
   sortAlbumsTracksChronologically,
   sortAlphabetically,
   sortChronologically,
+  sortFlashesChronologically,
 } from '../util/wiki-data.js';
 
 import find, {bindFind} from '../util/find.js';
@@ -1154,6 +1155,7 @@ export function sortWikiDataArrays(wikiData) {
   Object.assign(wikiData, {
     albumData: sortChronologically(wikiData.albumData.slice()),
     trackData: sortAlbumsTracksChronologically(wikiData.trackData.slice()),
+    flashData: sortFlashesChronologically(wikiData.flashData.slice()),
   });
 
   // Re-link data arrays, so that every object has the new, sorted versions.