Skip to content

Commit

Permalink
feat(artist): use album images from last.fm
Browse files Browse the repository at this point in the history
angristan committed Jul 7, 2022
1 parent 8de1935 commit dc83436
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions firstfm/ViewModel/ArtistViewModel.swift
Original file line number Diff line number Diff line change
@@ -52,16 +52,17 @@ class ArtistViewModel: ObservableObject {
self.setIsLoading()
}

for (index, album) in data.topalbums.album.enumerated() {
// Get image URL for each track and trigger a View update through the observed object
SpotifyImage.findImage(type: "album", name: album.name) { imageURL in
if let imageURL = imageURL {
DispatchQueue.main.async {
self.albums[index].image[0].url = imageURL
}
}
}
}
// Albums are still returned by the last.fm API, so we don't need to contact Spotify
// for (index, album) in data.topalbums.album.enumerated() {
// // Get image URL for each track and trigger a View update through the observed object
// SpotifyImage.findImage(type: "album", name: album.name) { imageURL in
// if let imageURL = imageURL {
// DispatchQueue.main.async {
// self.albums[index].image[0].url = imageURL
// }
// }
// }
// }
}
}
}
2 changes: 1 addition & 1 deletion firstfm/Views/Artist/TopArtistAlbumsView.swift
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ struct TopArtistAlbumsView: View {
destination: AlbumView(album: album),
label: {
VStack {
KFImage.url(URL(string: album.image[0].url != "" ? album.image[0].url : "https://lastfm.freetls.fastly.net/i/u/64s/4128a6eb29f94943c9d206c08e625904.webp")!)
KFImage.url(URL(string: album.image[3].url != "" ? album.image[3].url : "https://lastfm.freetls.fastly.net/i/u/64s/4128a6eb29f94943c9d206c08e625904.webp")!)
.resizable()
.cornerRadius(5)
.aspectRatio(contentMode: .fill)

0 comments on commit dc83436

Please sign in to comment.