« get me outta code hell

otherReleases works on original release too - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-03-08 22:58:24 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-03-08 22:58:24 -0400
commit180bcfd0fce3631d13f46f3d27851e09acc05c63 (patch)
tree1d39a650f31076347104a0128b9a0866927b0a7f
parentfc6561a9b8603f2ab7732991b5b68a316413c1d2 (diff)
otherReleases works on original release too
-rw-r--r--src/data/things.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/data/things.js b/src/data/things.js
index c873f5e3..b48642a6 100644
--- a/src/data/things.js
+++ b/src/data/things.js
@@ -716,33 +716,32 @@ Track.propertyDescriptors = {
         }
     },
 
+    originalReleaseTrack: Thing.common.dynamicThingFromSingleReference('originalReleaseTrackByRef', 'trackData', find.track),
+
     otherReleases: {
         flags: {expose: true},
 
         expose: {
             dependencies: ['originalReleaseTrackByRef', 'trackData'],
 
-            compute: ({ originalReleaseTrackByRef: ref1, trackData, [Track.instance]: t1 }) => {
-                if (!(ref1 && trackData)) {
+            compute: ({ originalReleaseTrackByRef: t1origRef, trackData, [Track.instance]: t1 }) => {
+                if (!trackData) {
                     return [];
                 }
 
-                const tOrig = find.track(ref1, trackData);
-                if (!tOrig) {
-                    return [];
-                }
+                const t1orig = find.track(t1origRef, trackData);
 
                 return [
-                    tOrig,
+                    t1orig,
                     ...trackData.filter(t2 => {
-                        const { originalReleaseTrackByRef: ref2 } = t2;
+                        const { originalReleaseTrack: t2orig } = t2;
                         return (
                             t2 !== t1 &&
-                            ref2 &&
-                            find.track(ref2, trackData) === tOrig
+                            t2orig &&
+                            (t2orig === t1orig || t2orig === t1)
                         );
                     })
-                ];
+                ].filter(Boolean);
             }
         }
     },