From ee46a4f78f1bfc8348834fbd3349849148f178a8 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 8 Sep 2023 10:54:58 -0300 Subject: data: Album.coverArt{Date,FileExtension}: depend on contribs --- src/data/things/album.js | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/data/things') diff --git a/src/data/things/album.js b/src/data/things/album.js index 88308182..3726a463 100644 --- a/src/data/things/album.js +++ b/src/data/things/album.js @@ -2,6 +2,13 @@ import find from '#find'; import {empty} from '#sugar'; import {isDate, isDimensions, isTrackSectionList} from '#validators'; +import { + compositeFrom, + exitWithoutDependency, + exposeDependency, + exposeUpdateValueOrContinue, +} from '#composite'; + import Thing, { additionalFiles, commentary, @@ -18,6 +25,7 @@ import Thing, { simpleString, urls, wikiData, + withResolvedContribs, } from './thing.js'; export class Album extends Thing { @@ -35,19 +43,16 @@ export class Album extends Thing { trackArtDate: simpleDate(), dateAddedToWiki: simpleDate(), - coverArtDate: { - flags: {update: true, expose: true}, + coverArtDate: compositeFrom(`Album.coverArtDate`, [ + withResolvedContribs({from: 'coverArtistContribs'}), + exitWithoutDependency({dependency: '#resolvedContribs', mode: 'empty'}), - update: {validate: isDate}, - - expose: { - dependencies: ['date', 'coverArtistContribs'], - transform: (coverArtDate, {coverArtistContribs, date}) => - (!empty(coverArtistContribs) - ? coverArtDate ?? date ?? null - : null), - }, - }, + exposeUpdateValueOrContinue(), + exposeDependency({ + dependency: 'date', + update: {validate: isDate}, + }), + ]), artistContribs: contributionList(), coverArtistContribs: contributionList(), @@ -102,7 +107,12 @@ export class Album extends Thing { }, }, - coverArtFileExtension: fileExtension('jpg'), + coverArtFileExtension: compositeFrom(`Album.coverArtFileExtension`, [ + withResolvedContribs({from: 'coverArtistContribs'}), + exitWithoutDependency({dependency: '#resolvedContribs', mode: 'empty'}), + fileExtension('jpg'), + ]), + trackCoverArtFileExtension: fileExtension('jpg'), wallpaperStyle: simpleString(), -- cgit 1.3.0-6-gf8a5