« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/data/things.js37
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
+                        );
+                    })
+                ];
+            }
         }
     },