diff options
Diffstat (limited to 'src/data')
-rw-r--r-- | src/data/things/album.js | 9 | ||||
-rw-r--r-- | src/data/things/thing.js | 17 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js index 07859537..dc8d3189 100644 --- a/src/data/things/album.js +++ b/src/data/things/album.js @@ -23,6 +23,7 @@ import Thing, { contributionList, dimensions, directory, + exitWithoutContribs, fileExtension, flag, name, @@ -31,7 +32,6 @@ import Thing, { simpleString, urls, wikiData, - withResolvedContribs, withResolvedReferenceList, } from './thing.js'; @@ -51,9 +51,7 @@ export class Album extends Thing { dateAddedToWiki: simpleDate(), coverArtDate: [ - withResolvedContribs({from: 'coverArtistContribs'}), - exitWithoutDependency({dependency: '#resolvedContribs', mode: 'empty'}), - + exitWithoutContribs({contribs: 'coverArtistContribs'}), exposeUpdateValueOrContinue(), exposeDependency({ dependency: 'date', @@ -152,8 +150,7 @@ export class Album extends Thing { ], coverArtFileExtension: [ - withResolvedContribs({from: 'coverArtistContribs'}), - exitWithoutDependency({dependency: '#resolvedContribs', mode: 'empty'}), + exitWithoutContribs({contribs: 'coverArtistContribs'}), fileExtension('jpg'), ], diff --git a/src/data/things/thing.js b/src/data/things/thing.js index 52f0b773..fe9000b4 100644 --- a/src/data/things/thing.js +++ b/src/data/things/thing.js @@ -436,6 +436,23 @@ export function withResolvedContribs({ ]); } +// Shorthand for exiting if the contribution list (usually a property's update +// value) resolves to empty - ensuring that the later computed results are only +// returned if these contributions are present. +export function exitWithoutContribs({ + contribs, + value = null, +}) { + return compositeFrom(`exitWithoutContribs`, [ + withResolvedContribs({from: contribs}), + exitWithoutDependency({ + dependency: '#resolvedContribs', + mode: 'empty', + value, + }), + ]); +} + // Resolves a reference by using the provided find function to match it // within the provided thingData dependency. This will early exit if the // data dependency is null, or, if notFoundMode is set to 'exit', if the find |