From 1d5078c972c8b2f625aa341cf75cead82323f909 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 27 Feb 2022 08:55:10 -0400 Subject: avoid stray nulls in (a Track).otherReleases --- src/data/things.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/data/things.js b/src/data/things.js index 5aa43f30..c09f740c 100644 --- a/src/data/things.js +++ b/src/data/things.js @@ -671,21 +671,28 @@ Track.propertyDescriptors = { expose: { dependencies: ['originalReleaseTrackByRef', 'trackData'], - compute: ({ originalReleaseTrackByRef: ref1, trackData, [Track.instance]: t1 }) => ( - (ref1 && trackData - ? [ - find.track(ref1, {wikiData: {trackData}}), - ...trackData.filter(t2 => { - const { originalReleaseTrackByRef: ref2 } = t2; - return ( - t2 !== t1 && - ref2 && - ( - find.track(ref2, {wikiData: {trackData}}) === - find.track(ref1, {wikiData: {trackData}}))) - })] - : []) - ) + compute: ({ originalReleaseTrackByRef: ref1, trackData, [Track.instance]: t1 }) => { + if (!(ref1 && trackData)) { + return []; + } + + const tOrig = find.track(ref1, {wikiData: {trackData}}); + if (!tOrig) { + return []; + } + + return [ + tOrig, + ...trackData.filter(t2 => { + const { originalReleaseTrackByRef: ref2 } = t2; + return ( + t2 !== t1 && + ref2 && + find.track(ref2, {wikiData: {trackData}}) === tOrig + ); + }) + ]; + } } }, -- cgit 1.3.0-6-gf8a5