Fix incorrect logic for checking if progress object exists

This commit is contained in:
ronaldheft 2022-08-21 11:34:23 -04:00
parent 7745ccefab
commit 85382d2bb4

View file

@ -155,8 +155,13 @@ extension LocalMediaProgress {
static func fetchOrCreateLocalMediaProgress(localMediaProgressId: String?, localLibraryItemId: String?, localEpisodeId: String?) -> LocalMediaProgress? { static func fetchOrCreateLocalMediaProgress(localMediaProgressId: String?, localLibraryItemId: String?, localEpisodeId: String?) -> LocalMediaProgress? {
if let localMediaProgressId = localMediaProgressId { if let localMediaProgressId = localMediaProgressId {
return Database.shared.getLocalMediaProgress(localMediaProgressId: localMediaProgressId) // Check if it existing in the database, if not, we need to create it
} else if let localLibraryItemId = localLibraryItemId { if let progress = Database.shared.getLocalMediaProgress(localMediaProgressId: localMediaProgressId) {
return progress
}
}
if let localLibraryItemId = localLibraryItemId {
guard let localLibraryItem = Database.shared.getLocalLibraryItem(localLibraryItemId: localLibraryItemId) else { return nil } guard let localLibraryItem = Database.shared.getLocalLibraryItem(localLibraryItemId: localLibraryItemId) else { return nil }
let episode = localLibraryItem.getPodcastEpisode(episodeId: localEpisodeId) let episode = localLibraryItem.getPodcastEpisode(episodeId: localEpisodeId)
return LocalMediaProgress(localLibraryItem: localLibraryItem, episode: episode) return LocalMediaProgress(localLibraryItem: localLibraryItem, episode: episode)