1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00

Refactor getAlbumForSongs

This commit is contained in:
Daniel Barber 2019-06-08 16:53:53 -04:00
parent 44f2b1c238
commit e05698e766
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8

View File

@ -95,15 +95,21 @@ class AlbumDetailView: NSViewController {
func getAlbumSongs(for album: Album) {
App.mpdClient.getAlbumSongs(for: album.mpdAlbum) { [weak self] (mpdSongs: [MPDClient.MPDSong]) in
self?.dataSource.setAlbumSongs(
guard let self = self else { return }
self.dataSource.setAlbumSongs(
mpdSongs.map { Song(mpdSong: $0) }
)
self?.getBigCoverArt(song: self?.dataSource.albumSongs.first!.song ?? (self?.dataSource.albumSongs[1].song!)!)
DispatchQueue.main.async {
self?.albumTracksView.reloadData()
self.albumTracksView.reloadData()
}
guard let song = self.dataSource.albumSongs.first?.song ??
self.dataSource.albumSongs[1].song
else { return }
self.getBigCoverArt(song: song)
}
}
@ -111,11 +117,9 @@ class AlbumDetailView: NSViewController {
let coverArtService = CoverArtService(song: song)
coverArtService.fetchBigCoverArt()
.done() { [weak self] image in
DispatchQueue.main.async {
if let image = image {
self?.albumCoverView.image = image
}
.done(on: DispatchQueue.main) { [weak self] image in
if let image = image {
self?.albumCoverView.image = image
}
}
.cauterize()