mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-23 19:26:50 +00:00
feat: update media selection logic to handle offline state in view models and DTOs
This commit is contained in:
@@ -37,7 +37,7 @@ class OfflineLocalMediaRepository @Inject constructor(
|
||||
}
|
||||
|
||||
override suspend fun getSeries(id: UUID): Flow<Series?> {
|
||||
return series.map { it[id] }
|
||||
return localDataSource.observeSeriesWithContent(id)
|
||||
}
|
||||
|
||||
override suspend fun getEpisode(id: UUID): Flow<Episode?> {
|
||||
|
||||
@@ -15,10 +15,10 @@ interface EpisodeDao {
|
||||
@Upsert
|
||||
suspend fun upsertAll(episodes: List<EpisodeEntity>)
|
||||
|
||||
@Query("SELECT * FROM episodes WHERE seriesId = :seriesId")
|
||||
@Query("SELECT * FROM episodes WHERE seriesId = :seriesId ORDER BY seasonIndex ASC, `index` ASC")
|
||||
suspend fun getBySeriesId(seriesId: UUID): List<EpisodeEntity>
|
||||
|
||||
@Query("SELECT * FROM episodes WHERE seasonId = :seasonId")
|
||||
@Query("SELECT * FROM episodes WHERE seasonId = :seasonId ORDER BY `index` ASC")
|
||||
suspend fun getBySeasonId(seasonId: UUID): List<EpisodeEntity>
|
||||
|
||||
@Query("SELECT * FROM episodes")
|
||||
|
||||
@@ -14,7 +14,7 @@ interface SeasonDao {
|
||||
@Upsert
|
||||
suspend fun upsertAll(seasons: List<SeasonEntity>)
|
||||
|
||||
@Query("SELECT * FROM seasons WHERE seriesId = :seriesId")
|
||||
@Query("SELECT * FROM seasons WHERE seriesId = :seriesId ORDER BY `index` ASC")
|
||||
suspend fun getBySeriesId(seriesId: UUID): List<SeasonEntity>
|
||||
|
||||
@Query("SELECT * FROM seasons WHERE id = :id")
|
||||
|
||||
@@ -43,11 +43,12 @@ class OfflineRoomMediaLocalDataSource(
|
||||
seriesDao.observeWithContent(seriesId).map { relation ->
|
||||
relation?.let {
|
||||
it.series.toDomain(
|
||||
seasons = it.seasons.map { swe ->
|
||||
seasons = it.seasons.sortedBy { swe -> swe.season.index }.map { swe ->
|
||||
swe.season.toDomain(
|
||||
episodes = swe.episodes.map { ep -> ep.toDomain() }
|
||||
episodes = swe.episodes.sortedBy { ep -> ep.index }.map { ep -> ep.toDomain() }
|
||||
)
|
||||
} )
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user