diff --git a/ios/App/Shared/models/local/LocalMediaProgress.swift b/ios/App/Shared/models/local/LocalMediaProgress.swift index 746b2e75..8962673d 100644 --- a/ios/App/Shared/models/local/LocalMediaProgress.swift +++ b/ios/App/Shared/models/local/LocalMediaProgress.swift @@ -155,8 +155,13 @@ extension LocalMediaProgress { static func fetchOrCreateLocalMediaProgress(localMediaProgressId: String?, localLibraryItemId: String?, localEpisodeId: String?) -> LocalMediaProgress? { if let localMediaProgressId = localMediaProgressId { - return Database.shared.getLocalMediaProgress(localMediaProgressId: localMediaProgressId) - } else if let localLibraryItemId = localLibraryItemId { + // Check if it existing in the database, if not, we need to create it + 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 } let episode = localLibraryItem.getPodcastEpisode(episodeId: localEpisodeId) return LocalMediaProgress(localLibraryItem: localLibraryItem, episode: episode)