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

Compare commits

..

2 Commits

Author SHA1 Message Date
87259920e8
Attempt to fix album detail view crash
Very occasionally the album detail view fails to get the album tracks
and this causes a crash. This extra guard avoids the crash, but doesn't
fix the underlying problem.

The problem itself is very hard to track down because it's incredibly
hard to reproduce.
2020-02-14 16:29:30 -05:00
448165d786
Fix potential race 2020-02-14 14:54:52 -05:00

View File

@ -113,20 +113,21 @@ class AlbumDetailView: NSViewController {
}
func getAlbumSongs(for album: Album) {
App.mpdClient.getAlbumSongs(for: album.mpdAlbum) { [self] (mpdSongs: [MPDClient.MPDSong]) in
self.dataSource.setAlbumSongs(
mpdSongs.map { Song(mpdSong: $0) }
)
App.mpdClient.getAlbumSongs(for: album.mpdAlbum) { [weak self] (mpdSongs: [MPDClient.MPDSong]) in
guard let self = self else { return }
DispatchQueue.main.async {
self.dataSource.setAlbumSongs(
mpdSongs.map { Song(mpdSong: $0) }
)
self.albumTracksView.reloadData()
}
guard let song = self.dataSource.albumSongs.first?.song ??
self.dataSource.albumSongs[1].song
else { return }
guard !self.dataSource.albumSongs.isEmpty,
let song = self.dataSource.albumSongs.first?.song ??
self.dataSource.albumSongs[1].song
else { return }
DispatchQueue.main.async {
self.getBigCoverArt(song: song, album: album)
}
}