« 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/util/search-spec.js32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/util/search-spec.js b/src/util/search-spec.js
index dc58b276..7e5b2b63 100644
--- a/src/util/search-spec.js
+++ b/src/util/search-spec.js
@@ -133,19 +133,33 @@ export const searchSpec = {
         'wallpaperArtistContribs',
       ];
 
-      fields.contributors =
+      const contributions =
         contribKeys
           .filter(key => Object.hasOwn(thing, key))
-          .flatMap(key => thing[key])
-          .map(contrib => contrib.artist)
-          .flatMap(artist => [artist.name, ...artist.aliasNames]);
+          .flatMap(key => thing[key]);
+
+      fields.contributors =
+        contributions
+          .flatMap(({artist}) => [
+            artist.name,
+            ...artist.aliasNames,
+          ]);
+
+      const groups =
+         (Object.hasOwn(thing, 'groups')
+           ? thing.groups
+        : Object.hasOwn(thing, 'album')
+           ? thing.album.groups
+           : []);
+
+      const mainContributorNames =
+        contributions
+          .map(({artist}) => artist.name);
 
       fields.groups =
-        (Object.hasOwn(thing, 'groups')
-          ? thing.groups.map(group => group.name)
-       : Object.hasOwn(thing, 'album')
-          ? thing.album.groups.map(group => group.name)
-          : []);
+        groups
+          .filter(group => !mainContributorNames.includes(group.name))
+          .map(group => group.name);
 
       fields.artwork =
         prepareArtwork(thing, opts);