diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-02-27 08:55:10 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-02-27 08:55:10 -0400 |
commit | 1d5078c972c8b2f625aa341cf75cead82323f909 (patch) | |
tree | 8dc214bc0cb4add1f7ed24a93e442f99e9f87e30 | |
parent | 6e2df0d972dcfa45be1e5f7f070fdebb969f4498 (diff) |
avoid stray nulls in (a Track).otherReleases
-rw-r--r-- | src/data/things.js | 37 |
1 files changed, 22 insertions, 15 deletions
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 + ); + }) + ]; + } } }, |