mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Refactor getAlbumForSongs
This commit is contained in:
parent
52fce2c212
commit
6629c4e91b
@ -97,15 +97,21 @@ class AlbumDetailView: NSViewController {
|
|||||||
|
|
||||||
func getAlbumSongs(for album: Album) {
|
func getAlbumSongs(for album: Album) {
|
||||||
App.mpdClient.getAlbumSongs(for: album.mpdAlbum) { [weak self] (mpdSongs: [MPDClient.MPDSong]) in
|
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) }
|
mpdSongs.map { Song(mpdSong: $0) }
|
||||||
)
|
)
|
||||||
|
|
||||||
self?.getBigCoverArt(song: self?.dataSource.albumSongs.first!.song ?? (self?.dataSource.albumSongs[1].song!)!)
|
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,13 +119,11 @@ class AlbumDetailView: NSViewController {
|
|||||||
let coverArtService = CoverArtService(song: song)
|
let coverArtService = CoverArtService(song: song)
|
||||||
|
|
||||||
coverArtService.fetchBigCoverArt()
|
coverArtService.fetchBigCoverArt()
|
||||||
.done() { [weak self] image in
|
.done(on: DispatchQueue.main) { [weak self] image in
|
||||||
DispatchQueue.main.async {
|
|
||||||
if let image = image {
|
if let image = image {
|
||||||
self?.albumCoverView.image = image
|
self?.albumCoverView.image = image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.cauterize()
|
.cauterize()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user