mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-23 19:26:50 +00:00
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:
@@ -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(
|
private suspend fun <T> getFromActiveRepository(
|
||||||
onlineRead: suspend () -> Flow<T>,
|
onlineRead: suspend () -> Flow<T>,
|
||||||
offlineRead: suspend () -> Flow<T>,
|
offlineRead: suspend () -> Flow<T>,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
interface LocalMediaRepository : LocalMediaUpdater {
|
interface LocalMediaRepository : MediaMetadataUpdater {
|
||||||
val movies: StateFlow<Map<UUID, Movie>>
|
val movies: StateFlow<Map<UUID, Movie>>
|
||||||
val series: StateFlow<Map<UUID, Series>>
|
val series: StateFlow<Map<UUID, Series>>
|
||||||
val episodes: StateFlow<Map<UUID, Episode>>
|
val episodes: StateFlow<Map<UUID, Episode>>
|
||||||
|
|||||||
@@ -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)
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@ import dagger.hilt.InstallIn
|
|||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
import hu.bbara.purefin.core.data.CompositeLocalMediaRepository
|
import hu.bbara.purefin.core.data.CompositeLocalMediaRepository
|
||||||
import hu.bbara.purefin.core.data.LocalMediaRepository
|
import hu.bbara.purefin.core.data.LocalMediaRepository
|
||||||
import hu.bbara.purefin.core.data.LocalMediaUpdater
|
|
||||||
|
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@@ -15,7 +14,4 @@ abstract class RepositoryModule {
|
|||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
abstract fun bindMediaRepository(impl: CompositeLocalMediaRepository): LocalMediaRepository
|
abstract fun bindMediaRepository(impl: CompositeLocalMediaRepository): LocalMediaRepository
|
||||||
|
|
||||||
@Binds
|
|
||||||
abstract fun bindMediaProgressWrite(impl: CompositeLocalMediaRepository): LocalMediaUpdater
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
private fun updateLoadedSeriesEpisode(updatedEpisode: Episode) {
|
||||||
seriesState.update { current ->
|
seriesState.update { current ->
|
||||||
val series = current[updatedEpisode.seriesId] ?: return@update current
|
val series = current[updatedEpisode.seriesId] ?: return@update current
|
||||||
|
|||||||
@@ -71,6 +71,14 @@ class OfflineLocalMediaRepository @Inject constructor(
|
|||||||
// Do nothing
|
// 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>) {
|
override suspend fun saveMovies(movies: List<Movie>) {
|
||||||
localDataSource.saveMovies(movies)
|
localDataSource.saveMovies(movies)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user