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

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.
This commit is contained in:
Daniel Barber 2020-02-14 16:29:30 -05:00
parent eb5cee2a75
commit a7e7620f68
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8

View File

@ -113,15 +113,18 @@ 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 ??
guard !self.dataSource.albumSongs.isEmpty,
let song = self.dataSource.albumSongs.first?.song ??
self.dataSource.albumSongs[1].song
else { return }