mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-24 03:36:51 +00:00
fix(repository): merge existing seasons when updating series with empty seasons
This commit is contained in:
@@ -79,7 +79,15 @@ class InMemoryLocalMediaRepository @Inject constructor(
|
|||||||
return@run
|
return@run
|
||||||
}
|
}
|
||||||
val series = item.toSeries(serverUrl.first())
|
val series = item.toSeries(serverUrl.first())
|
||||||
seriesState.update { current -> current + (series.id to series) }
|
seriesState.update { current ->
|
||||||
|
val existing = current[series.id]
|
||||||
|
val merged = if (existing != null && existing.seasons.isNotEmpty() && series.seasons.isEmpty()) {
|
||||||
|
series.copy(seasons = existing.seasons)
|
||||||
|
} else {
|
||||||
|
series
|
||||||
|
}
|
||||||
|
current + (series.id to merged)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error: CancellationException) {
|
} catch (error: CancellationException) {
|
||||||
throw error
|
throw error
|
||||||
|
|||||||
Reference in New Issue
Block a user