From ea2e91a7ef5c38ecea57222601eae469e7d700f4 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 7 Mar 2024 12:27:34 -0400 Subject: data: withCoverArtDate refactor, make Album.coverArtDate updatable --- src/data/composite/wiki-data/withCoverArtDate.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/data/composite/wiki-data') diff --git a/src/data/composite/wiki-data/withCoverArtDate.js b/src/data/composite/wiki-data/withCoverArtDate.js index 7c16ce0f..0c644c77 100644 --- a/src/data/composite/wiki-data/withCoverArtDate.js +++ b/src/data/composite/wiki-data/withCoverArtDate.js @@ -3,6 +3,7 @@ // any coverArtistContribs. import {input, templateCompositeFrom} from '#composite'; +import {isDate} from '#validators'; import {raiseOutputWithoutDependency} from '#composite/control-flow'; @@ -12,6 +13,12 @@ export default templateCompositeFrom({ annotation: `withCoverArtDate`, inputs: { + from: input({ + validate: isDate, + defaultDependency: 'coverArtDate', + acceptsNull: true, + }), + fallback: input({ type: 'boolean', defaultValue: false, @@ -33,14 +40,21 @@ export default templateCompositeFrom({ }), { - dependencies: ['coverArtDate', input('fallback')], + dependencies: [input('from')], + compute: (continuation, { + [input('from')]: from, + }) => + (from + ? continuation.raiseOutput({'#coverArtDate': from}) + : continuation()), + }, + + { + dependencies: [input('fallback')], compute: (continuation, { - ['coverArtDate']: coverArtDate, [input('fallback')]: fallback, }) => - (coverArtDate - ? continuation.raiseOutput({'#coverArtDate': coverArtDate}) - : fallback + (fallback ? continuation() : continuation.raiseOutput({'#coverArtDate': null})), }, -- cgit 1.3.0-6-gf8a5