mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-24 03:36:51 +00:00
fix(catalog): preserve cached episodes when refreshing seasons
This commit is contained in:
@@ -145,8 +145,16 @@ class InMemoryLocalMediaRepository @Inject constructor(
|
||||
series = seriesState.first()[seriesId] ?: throw RuntimeException("Series not found")
|
||||
}
|
||||
|
||||
val existingSeasonsById = series.seasons.associateBy { it.id }
|
||||
val updatedSeries = series.copy(
|
||||
seasons = jellyfinApiClient.getSeasons(seriesId).map { it.toSeason() }
|
||||
seasons = jellyfinApiClient.getSeasons(seriesId).map { it.toSeason() }.map { fresh ->
|
||||
val existing = existingSeasonsById[fresh.id]
|
||||
if (existing != null && existing.episodes.isNotEmpty()) {
|
||||
fresh.copy(episodes = existing.episodes)
|
||||
} else {
|
||||
fresh
|
||||
}
|
||||
}
|
||||
)
|
||||
seriesState.update { it + (updatedSeries.id to updatedSeries) }
|
||||
} catch (error: CancellationException) {
|
||||
|
||||
Reference in New Issue
Block a user