From 079b2bb3ed1561b1953139a03a31b37c9da868c4 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 24 Apr 2024 17:08:45 -0300 Subject: data: withReverse{Reference,Contribution}List: better exiting An existing test for withAlbum (which is semi-newly based on withUniqueReferencingThing, and thus withReverseReferenceList) indicates that if we just can't *find* the album in a provided data array, that's not an exit condition. This commit adapts withReverseReferencingList to respect that when the data list is empty. (Treating an empty array as the same thing as an array that isn't provided at all - the existing behavior - is really just a bug!) --- src/data/composite/wiki-data/withReverseContributionList.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/data/composite/wiki-data/withReverseContributionList.js') diff --git a/src/data/composite/wiki-data/withReverseContributionList.js b/src/data/composite/wiki-data/withReverseContributionList.js index c5dcad07..91e125e4 100644 --- a/src/data/composite/wiki-data/withReverseContributionList.js +++ b/src/data/composite/wiki-data/withReverseContributionList.js @@ -11,7 +11,8 @@ import {input, templateCompositeFrom} from '#composite'; -import {exitWithoutDependency} from '#composite/control-flow'; +import {exitWithoutDependency, raiseOutputWithoutDependency} + from '#composite/control-flow'; import inputWikiData from './inputWikiData.js'; @@ -32,10 +33,17 @@ export default templateCompositeFrom({ outputs: ['#reverseContributionList'], steps: () => [ + // Early exit with an empty array if the data list isn't available. exitWithoutDependency({ dependency: input('data'), value: input.value([]), + }), + + // Raise an empty array (don't early exit) if the data list is empty. + raiseOutputWithoutDependency({ + dependency: input('data'), mode: input.value('empty'), + output: input.value({'#reverseContributionList': []}), }), { -- cgit 1.3.0-6-gf8a5