From 7e0dfb0f797b6dabad4a4491ef8e7333cc199926 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 27 Apr 2023 16:03:04 -0300 Subject: data: track: null coverArtistContribs if hasTrackArt false Fixes #178. This commit also cleans up the documentation for the utility used here, dynamicInheritContribs. These are the only two uses of that utility at all but like, code comments very rarely hurt and d'accord are probably even more useful here lol --- src/data/things/thing.js | 26 +++++++++++++++++++++----- src/data/things/track.js | 2 ++ 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src/data') diff --git a/src/data/things/thing.js b/src/data/things/thing.js index 5ab15c0e..9c59436e 100644 --- a/src/data/things/thing.js +++ b/src/data/things/thing.js @@ -262,26 +262,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', -- cgit 1.3.0-6-gf8a5 From 6128ba16c1b5c4c6095e0ddba0977817cce4bc6e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 27 Apr 2023 16:55:06 -0300 Subject: data: new sortByPositionInFlash act function Fixes #168. This refactors the duplicated logic with sortByPositionInAlbum into a new template, sortByPositionInParent. --- src/data/yaml.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/data') diff --git a/src/data/yaml.js b/src/data/yaml.js index 1b1195ea..de0b506b 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'; @@ -1155,6 +1156,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. -- cgit 1.3.0-6-gf8a5