From db2ebb010aada0739773769cbaf3c34a9763c1fd Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 13 May 2024 11:40:16 -0300 Subject: search: don't expose group names if they match an artist name --- src/util/search-spec.js | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'src') 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); -- cgit 1.3.0-6-gf8a5