refactor(media): remove LocalMediaUpdater interface in favor of MediaMetadataUpdater

Make LocalMediaRepository extend MediaMetadataUpdater directly instead of the
now-removed LocalMediaUpdater, eliminating the redundant intermediate interface.
Add no-op updatePlaybackPosition stubs to all LocalMediaRepository implementations
since server-side position tracking belongs in the remote layer of the composite.

JellyfinMediaMetadataUpdaterImpl continues to act as the composite that combines
LocalMediaRepository (local cache) with JellyfinApiClient (remote server) under
the single MediaMetadataUpdater contract.
This commit is contained in:
2026-06-12 18:40:22 +00:00
parent e78a3700a6
commit 8d74d0c5df
6 changed files with 29 additions and 14 deletions

View File

@@ -102,6 +102,18 @@ class CompositeLocalMediaRepository @Inject constructor(
)
}
override suspend fun updatePlaybackPosition(
mediaId: UUID,
playbackPositionTicks: Long,
runtimeTicks: Long,
) {
// Server-side operation — delegates to active repository (both are no-ops)
runOnlineOrOfflineNoOp(
onlineAction = { onlineRepository.updatePlaybackPosition(mediaId, playbackPositionTicks, runtimeTicks) },
offlineAction = { offlineRepository.updatePlaybackPosition(mediaId, playbackPositionTicks, runtimeTicks) },
)
}
private suspend fun <T> getFromActiveRepository(
onlineRead: suspend () -> Flow<T>,
offlineRead: suspend () -> Flow<T>,

View File

@@ -7,7 +7,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import java.util.UUID
interface LocalMediaRepository : LocalMediaUpdater {
interface LocalMediaRepository : MediaMetadataUpdater {
val movies: StateFlow<Map<UUID, Movie>>
val series: StateFlow<Map<UUID, Series>>
val episodes: StateFlow<Map<UUID, Episode>>

View File

@@ -1,9 +0,0 @@
package hu.bbara.purefin.core.data
import java.util.UUID
interface LocalMediaUpdater {
suspend fun updateWatchProgress(mediaId: UUID, positionMs: Long, durationMs: Long)
suspend fun updateWatchProgressPercent(mediaId: UUID, progressPercent: Double)
suspend fun markAsWatched(mediaId: UUID, watched: Boolean)
}

View File

@@ -6,7 +6,6 @@ import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import hu.bbara.purefin.core.data.CompositeLocalMediaRepository
import hu.bbara.purefin.core.data.LocalMediaRepository
import hu.bbara.purefin.core.data.LocalMediaUpdater
@Module
@@ -15,7 +14,4 @@ abstract class RepositoryModule {
@Binds
abstract fun bindMediaRepository(impl: CompositeLocalMediaRepository): LocalMediaRepository
@Binds
abstract fun bindMediaProgressWrite(impl: CompositeLocalMediaRepository): LocalMediaUpdater
}

View File

@@ -214,6 +214,14 @@ class InMemoryLocalMediaRepository @Inject constructor(
}
}
override suspend fun updatePlaybackPosition(
mediaId: UUID,
playbackPositionTicks: Long,
runtimeTicks: Long,
) {
// Server-side operation — not persisted locally
}
private fun updateLoadedSeriesEpisode(updatedEpisode: Episode) {
seriesState.update { current ->
val series = current[updatedEpisode.seriesId] ?: return@update current

View File

@@ -71,6 +71,14 @@ class OfflineLocalMediaRepository @Inject constructor(
// Do nothing
}
override suspend fun updatePlaybackPosition(
mediaId: UUID,
playbackPositionTicks: Long,
runtimeTicks: Long,
) {
// Server-side operation — not persisted offline
}
override suspend fun saveMovies(movies: List<Movie>) {
localDataSource.saveMovies(movies)
}