Bugfix for tag traversal in anime ID retrieval

This commit is contained in:
Eduard Urbach 2018-11-10 13:59:04 +09:00
parent 305c20f5a6
commit 8e1196cd98

View File

@ -289,8 +289,13 @@ export default class AudioPlayer {
this.trackLink.href = "/soundtrack/" + track.id this.trackLink.href = "/soundtrack/" + track.id
this.trackLink.textContent = track.title.canonical || track.title.native this.trackLink.textContent = track.title.canonical || track.title.native
// Find anime ID by looking at the tags
let animeId = "" let animeId = ""
if(!track.tags) {
return
}
for(let tag of (track.tags as string[])) { for(let tag of (track.tags as string[])) {
if(tag.startsWith("anime:")) { if(tag.startsWith("anime:")) {
animeId = tag.split(":")[1] animeId = tag.split(":")[1]
@ -298,8 +303,11 @@ export default class AudioPlayer {
} }
} }
if(animeId === "") {
return
}
// Set anime info // Set anime info
if(animeId !== "") {
this.animeInfo.classList.remove("hidden") this.animeInfo.classList.remove("hidden")
let animeResponse = await fetch("/api/anime/" + animeId) let animeResponse = await fetch("/api/anime/" + animeId)
let anime = await animeResponse.json() as Anime let anime = await animeResponse.json() as Anime
@ -310,4 +318,3 @@ export default class AudioPlayer {
this.animeImage["became visible"]() this.animeImage["became visible"]()
} }
} }
}