From 7a858a2db31dc42d724fbaaccff32663bb329b2c Mon Sep 17 00:00:00 2001 From: Kendall Garner <17521368+kgarner7@users.noreply.github.com> Date: Fri, 17 Nov 2023 00:07:52 +0000 Subject: [PATCH] Fix external link for artist page if LastFM is missinb but Musicbrainz is not (#2533) * fix mbz link if lastfm does not exist * use lastfmUrl field * fix artist info undefined --- ui/src/artist/ArtistExternalLink.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ui/src/artist/ArtistExternalLink.js b/ui/src/artist/ArtistExternalLink.js index 37faddc28..c25f19ffd 100644 --- a/ui/src/artist/ArtistExternalLink.js +++ b/ui/src/artist/ArtistExternalLink.js @@ -9,19 +9,11 @@ import config from '../config' const ArtistExternalLinks = ({ artistInfo, record }) => { const translate = useTranslate() - let links = [] let linkButtons = [] const lastFMlink = artistInfo?.biography?.match( /]*?\s+)?href=(["'])(.*?)\1/ ) - if (lastFMlink) { - links.push(lastFMlink[2]) - } - if (artistInfo && artistInfo.musicBrainzId) { - links.push(`https://musicbrainz.org/artist/${artistInfo.musicBrainzId}`) - } - const addLink = (url, title, icon) => { const translatedTitle = translate(title) const link = ( @@ -38,16 +30,24 @@ const ArtistExternalLinks = ({ artistInfo, record }) => { } if (config.lastFMEnabled) { - addLink( - links[0], - 'message.openIn.lastfm', - - ) + if (lastFMlink) { + addLink( + lastFMlink[2], + 'message.openIn.lastfm', + + ) + } else if (artistInfo?.lastFmUrl) { + addLink( + artistInfo?.lastFmUrl, + 'message.openIn.lastfm', + + ) + } } artistInfo?.musicBrainzId && addLink( - links[1], + `https://musicbrainz.org/artist/${artistInfo.musicBrainzId}`, 'message.openIn.musicbrainz', )