« get me outta code hell

data, test: filter out empty track sections - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-09 18:31:09 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-09 18:32:07 -0300
commitb06c194fc02da22564bcb165db33282f411859a3 (patch)
tree2b59b4924c0d0fbbed015e6eac7649a2549f5fd1 /src/data
parent666ce1d6c2e1b93e34222c2b2b999ff32a1c6ca8 (diff)
data, test: filter out empty track sections
Also test unmatched track references.
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/album.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 9ca662a0..7569eb80 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -1,6 +1,7 @@
 import find from '#find';
-import {stitchArrays} from '#sugar';
+import {empty, stitchArrays} from '#sugar';
 import {isDate, isTrackSectionList} from '#validators';
+import {filterMultipleArrays} from '#wiki-data';
 
 import {
   exitWithoutDependency,
@@ -152,20 +153,25 @@ export class Album extends Thing {
             '#sections.startIndex',
           ],
 
-          transform: (trackSections, {
+          transform(trackSections, {
             '#sections.tracks': tracks,
             '#sections.color': color,
             '#sections.dateOriginallyReleased': dateOriginallyReleased,
             '#sections.isDefaultTrackSection': isDefaultTrackSection,
             '#sections.startIndex': startIndex,
-          }) =>
-            stitchArrays({
+          }) {
+            filterMultipleArrays(
+              tracks, color, dateOriginallyReleased, isDefaultTrackSection, startIndex,
+              tracks => !empty(tracks));
+
+            return stitchArrays({
               tracks,
               color,
               dateOriginallyReleased,
               isDefaultTrackSection,
               startIndex,
-            }),
+            });
+          }
         },
       },
     ],