mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-22 17:41:39 +00:00
delete: Remove genre loading and storage from LocalMediaRepository
This commit is contained in:
@@ -3,7 +3,6 @@ package hu.bbara.purefin.data
|
||||
import hu.bbara.purefin.Offline
|
||||
import hu.bbara.purefin.Online
|
||||
import hu.bbara.purefin.model.Episode
|
||||
import hu.bbara.purefin.model.Genre
|
||||
import hu.bbara.purefin.model.Movie
|
||||
import hu.bbara.purefin.model.Series
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -44,10 +43,6 @@ class CompositeLocalMediaRepository @Inject constructor(
|
||||
.flatMapLatest { it.episodes }
|
||||
.stateIn(scope, Eagerly, emptyMap())
|
||||
|
||||
override val genres: StateFlow<Set<Genre>> = activeRepository
|
||||
.flatMapLatest { it.genres }
|
||||
.stateIn(scope, Eagerly, emptySet())
|
||||
|
||||
override suspend fun getMovie(id: UUID): Flow<Movie?> {
|
||||
return activeRepository
|
||||
.flatMapLatest { it.getMovie(id) }
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package hu.bbara.purefin.data
|
||||
|
||||
import hu.bbara.purefin.model.Episode
|
||||
import hu.bbara.purefin.model.Genre
|
||||
import hu.bbara.purefin.model.Movie
|
||||
import hu.bbara.purefin.model.Series
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -12,7 +11,6 @@ interface LocalMediaRepository : LocalMediaUpdater {
|
||||
val movies: StateFlow<Map<UUID, Movie>>
|
||||
val series: StateFlow<Map<UUID, Series>>
|
||||
val episodes: StateFlow<Map<UUID, Episode>>
|
||||
val genres: StateFlow<Set<Genre>>
|
||||
suspend fun getMovie(id: UUID): Flow<Movie?>
|
||||
suspend fun getSeries(id: UUID): Flow<Series?>
|
||||
suspend fun getEpisode(id: UUID): Flow<Episode?>
|
||||
|
||||
@@ -6,7 +6,6 @@ import hu.bbara.purefin.data.HomeRepository
|
||||
import hu.bbara.purefin.data.NetworkMonitor
|
||||
import hu.bbara.purefin.data.UserSessionRepository
|
||||
import hu.bbara.purefin.data.converter.toEpisode
|
||||
import hu.bbara.purefin.data.converter.toGenre
|
||||
import hu.bbara.purefin.data.converter.toLibrary
|
||||
import hu.bbara.purefin.data.converter.toMovie
|
||||
import hu.bbara.purefin.data.converter.toSeason
|
||||
@@ -101,7 +100,6 @@ class InMemoryAppContentRepository @Inject constructor(
|
||||
loadContinueWatching()
|
||||
loadNextUp()
|
||||
loadLatestLibraryContent()
|
||||
loadGenres()
|
||||
Log.d(TAG, "Home refresh successful")
|
||||
persistHomeCache()
|
||||
}.onFailure { error ->
|
||||
@@ -339,12 +337,6 @@ class InMemoryAppContentRepository @Inject constructor(
|
||||
latestLibraryContentState.value = latestLibraryContents
|
||||
}
|
||||
|
||||
private suspend fun loadGenres() {
|
||||
val baseItemDtos = jellyfinApiClient.getGenres()
|
||||
val genres = baseItemDtos.map { it.toGenre() }
|
||||
onlineMediaRepository.upsertGenres(genres.toSet())
|
||||
}
|
||||
|
||||
private suspend fun serverUrl(): String {
|
||||
return userSessionRepository.serverUrl.first()
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import hu.bbara.purefin.data.converter.toSeason
|
||||
import hu.bbara.purefin.data.converter.toSeries
|
||||
import hu.bbara.purefin.data.jellyfin.client.JellyfinApiClient
|
||||
import hu.bbara.purefin.model.Episode
|
||||
import hu.bbara.purefin.model.Genre
|
||||
import hu.bbara.purefin.model.Movie
|
||||
import hu.bbara.purefin.model.Series
|
||||
import kotlinx.coroutines.CancellationException
|
||||
@@ -49,9 +48,6 @@ class InMemoryLocalMediaRepository @Inject constructor(
|
||||
private val episodesState = MutableStateFlow<Map<UUID, Episode>>(emptyMap())
|
||||
override val episodes: StateFlow<Map<UUID, Episode>> = episodesState.asStateFlow()
|
||||
|
||||
private val genresState = MutableStateFlow<Set<Genre>>(emptySet())
|
||||
override var genres: StateFlow<Set<Genre>> = genresState.asStateFlow()
|
||||
|
||||
override suspend fun getMovie(id: UUID): Flow<Movie?> {
|
||||
if (!moviesState.value.containsKey(id)) {
|
||||
jellyfinApiClient.getItemInfo(id)?.let { item ->
|
||||
@@ -96,10 +92,6 @@ class InMemoryLocalMediaRepository @Inject constructor(
|
||||
return episodesState.map { it[id] }
|
||||
}
|
||||
|
||||
fun upsertGenres(genres: Set<Genre>) {
|
||||
genresState.update { current -> current + genres }
|
||||
}
|
||||
|
||||
fun upsertMovies(movies: List<Movie>) {
|
||||
moviesState.update { current -> current + movies.associateBy { it.id } }
|
||||
}
|
||||
|
||||
@@ -3,14 +3,12 @@ package hu.bbara.purefin.data.catalog
|
||||
import hu.bbara.purefin.data.LocalMediaRepository
|
||||
import hu.bbara.purefin.data.offline.room.offline.OfflineRoomMediaLocalDataSource
|
||||
import hu.bbara.purefin.model.Episode
|
||||
import hu.bbara.purefin.model.Genre
|
||||
import hu.bbara.purefin.model.Movie
|
||||
import hu.bbara.purefin.model.Series
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.map
|
||||
@@ -34,8 +32,6 @@ class OfflineLocalMediaRepository @Inject constructor(
|
||||
override val episodes: StateFlow<Map<UUID, Episode>> = localDataSource.episodesFlow
|
||||
.stateIn(scope, SharingStarted.Eagerly, emptyMap())
|
||||
|
||||
override var genres: StateFlow<Set<Genre>> = MutableStateFlow(emptySet())
|
||||
|
||||
override suspend fun getMovie(id: UUID): Flow<Movie?> {
|
||||
return movies.map { it[id] }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user