Skip to content

Commit

Permalink
Fix external link for artist page if LastFM is missinb but Musicbrain…
Browse files Browse the repository at this point in the history
…z is not (#2533)

* fix mbz link if lastfm does not exist

* use lastfmUrl field

* fix artist info undefined
  • Loading branch information
kgarner7 committed Nov 17, 2023
1 parent 9cefaf6 commit 7a858a2
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions ui/src/artist/ArtistExternalLink.js
Expand Up @@ -9,19 +9,11 @@ import config from '../config'

const ArtistExternalLinks = ({ artistInfo, record }) => {
const translate = useTranslate()
let links = []
let linkButtons = []
const lastFMlink = artistInfo?.biography?.match(
/<a\s+(?:[^>]*?\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 = (
Expand All @@ -38,16 +30,24 @@ const ArtistExternalLinks = ({ artistInfo, record }) => {
}

if (config.lastFMEnabled) {
addLink(
links[0],
'message.openIn.lastfm',
<ImLastfm2 className="lastfm-icon" />
)
if (lastFMlink) {
addLink(
lastFMlink[2],
'message.openIn.lastfm',
<ImLastfm2 className="lastfm-icon" />
)
} else if (artistInfo?.lastFmUrl) {
addLink(
artistInfo?.lastFmUrl,
'message.openIn.lastfm',
<ImLastfm2 className="lastfm-icon" />
)
}
}

artistInfo?.musicBrainzId &&
addLink(
links[1],
`https://musicbrainz.org/artist/${artistInfo.musicBrainzId}`,
'message.openIn.musicbrainz',
<MusicBrainz className="musicbrainz-icon" />
)
Expand Down

0 comments on commit 7a858a2

Please sign in to comment.