Skip to content

Commit

Permalink
Artist/Album: albumCount/songCount has fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
BLeeEZ committed Jun 9, 2021
1 parent 3ba54b4 commit f1554e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Amperfy/Storage/EntityWrappers/Album.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public class Album: AbstractLibraryEntity, SongContainable {
}
}
var songCount: Int {
get { return Int(managedObject.songCount) }
get {
let moSongCount = Int(managedObject.songCount)
return moSongCount != 0 ? moSongCount : (managedObject.songs?.count ?? 0)
}
set {
guard Int16.isValid(value: newValue), managedObject.songCount != Int16(newValue) else { return }
managedObject.songCount = Int16(newValue)
Expand Down
5 changes: 4 additions & 1 deletion Amperfy/Storage/EntityWrappers/Artist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public class Artist: AbstractLibraryEntity, SongContainable {
}
}
var albumCount: Int {
get { return Int(managedObject.albumCount) }
get {
let moAlbumCount = Int(managedObject.albumCount)
return moAlbumCount != 0 ? moAlbumCount : (managedObject.albums?.count ?? 0)
}
set {
guard Int16.isValid(value: newValue), managedObject.albumCount != Int16(newValue) else { return }
managedObject.albumCount = Int16(newValue)
Expand Down

0 comments on commit f1554e9

Please sign in to comment.