refactor: MediaProgressWriter to LocalMediaUpdater and add markAsWatched support

This commit is contained in:
2026-05-04 18:10:02 +02:00
parent ed80948676
commit bc4b26291f
7 changed files with 34 additions and 8 deletions

View File

@@ -146,6 +146,22 @@ class InMemoryLocalMediaRepository @Inject constructor(
}
}
override suspend fun markAsWatched(mediaId: UUID, watched: Boolean) {
if (moviesState.value.containsKey(mediaId)) {
moviesState.update { current ->
val movie = current[mediaId] ?: return@update current
current + (mediaId to movie.copy(watched = watched))
}
return
}
if (episodesState.value.containsKey(mediaId)) {
episodesState.update { current ->
val episode = current[mediaId] ?: return@update current
current + (mediaId to episode.copy(watched = watched))
}
}
}
private suspend fun ensureSeriesContentLoaded(seriesId: UUID) {
seriesState.value[seriesId]?.takeIf { it.seasons.isNotEmpty() }?.let { return }

View File

@@ -58,4 +58,8 @@ class OfflineLocalMediaRepository @Inject constructor(
val watched = progressPercent >= 90.0
localDataSource.updateWatchProgress(mediaId, progressPercent, watched)
}
override suspend fun markAsWatched(mediaId: UUID, watched: Boolean) {
// Do nothing
}
}