« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/page/album.js12
-rw-r--r--src/util/sugar.js5
2 files changed, 13 insertions, 4 deletions
diff --git a/src/page/album.js b/src/page/album.js
index d7447a4c..6bcff886 100644
--- a/src/page/album.js
+++ b/src/page/album.js
@@ -7,13 +7,14 @@ import fixWS from 'fix-whitespace';
 import * as html from '../util/html.js';
 
 import {
-    bindOpts
+    bindOpts,
+    compareArrays,
 } from '../util/sugar.js';
 
 import {
     getAlbumCover,
     getAlbumListTag,
-    getTotalDuration
+    getTotalDuration,
 } from '../util/wiki-data.js';
 
 // Page exports
@@ -36,13 +37,16 @@ export function write(album, {wikiData}) {
             track: link.track(track)
         };
         return `<li style="${getLinkThemeString(track.color)}">${
-            (track.artists === album.artists
+            (compareArrays(
+                track.artistContribs.map(c => c.who),
+                album.artistContribs.map(c => c.who),
+                {checkOrder: false})
                 ? strings('trackList.item.withDuration', itemOpts)
                 : strings('trackList.item.withDuration.withArtists', {
                     ...itemOpts,
                     by: `<span class="by">${
                         strings('trackList.item.withArtists.by', {
-                            artists: getArtistString(track.artists)
+                            artists: getArtistString(track.artistContribs)
                         })
                     }</span>`
                 }))
diff --git a/src/util/sugar.js b/src/util/sugar.js
index c8f1706c..7a132271 100644
--- a/src/util/sugar.js
+++ b/src/util/sugar.js
@@ -32,6 +32,11 @@ export const filterEmptyLines = string => string.split('\n').filter(line => line
 
 export const unique = arr => Array.from(new Set(arr));
 
+export const compareArrays = (arr1, arr2, {checkOrder = true} = {}) => (
+    arr1.length === arr2.length && (checkOrder
+        ? (arr1.every((x, i) => arr2[i] === x))
+        : (arr1.every(x => arr2.includes(x)))));
+
 // Stolen from jq! Which pro8a8ly stole the concept from other places. Nice.
 export const withEntries = (obj, fn) => Object.fromEntries(fn(Object.entries(obj)));