Skip to content

Commit

Permalink
fix(player): new episode duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
urFate committed Jan 17, 2025
1 parent f0fd645 commit 1858891
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class PlayerViewModel @AssistedInject constructor(
content = Util.mapEntityToContent(content),
contentUid = content.uid,
cachedEpisodes = cachedEpisodes,
team = team,
range = cachedEpisodes.last().episode.inc()..Int.MAX_VALUE
)
}
Expand Down
6 changes: 6 additions & 0 deletions data/src/main/java/org/shirabox/data/EpisodesHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.emitAll
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.map
import org.shirabox.core.db.AppDatabase
import org.shirabox.core.entity.EpisodeEntity
import org.shirabox.core.model.Content
Expand All @@ -28,12 +29,17 @@ class EpisodesHelper(private val db: AppDatabase) {
repository: AbstractContentRepository,
content: Content,
contentUid: Long,
team: String? = null,
cachedEpisodes: List<EpisodeEntity>,
range: IntRange
) {
repository.searchEpisodesInRange(content, range).catch {
it.printStackTrace()
emitAll(emptyFlow())
}.map { results ->
team?.let {
results.filter { episode -> episode.actingTeamName == it }
} ?: results
}.collectLatest {
cacheEpisodes(it, cachedEpisodes, contentUid)
}
Expand Down

0 comments on commit 1858891

Please sign in to comment.