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(
|
||||
onlineRead: suspend () -> Flow<T>,
|
||||
offlineRead: suspend () -> Flow<T>,
|
||||
|
||||
@@ -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>>
|
||||
|
||||
@@ -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 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user