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