mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-24 03:36:51 +00:00
refactor: rename media repository files for consistency
This commit is contained in:
@@ -48,7 +48,7 @@ class InMemoryAppContentRepository @Inject constructor(
|
||||
val userSessionRepository: UserSessionRepository,
|
||||
val jellyfinApiClient: JellyfinApiClient,
|
||||
private val homeCacheDataStore: DataStore<HomeCache>,
|
||||
private val onlineMediaRepository: InMemoryMediaRepository,
|
||||
private val onlineMediaRepository: InMemoryLocalMediaRepository,
|
||||
private val networkMonitor: NetworkMonitor,
|
||||
) : HomeRepository {
|
||||
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package hu.bbara.purefin.data.catalog
|
||||
|
||||
import android.util.Log
|
||||
import hu.bbara.purefin.data.MediaRepository
|
||||
import hu.bbara.purefin.data.LocalMediaRepository
|
||||
import hu.bbara.purefin.data.UserSessionRepository
|
||||
import hu.bbara.purefin.data.converter.toEpisode
|
||||
import hu.bbara.purefin.data.converter.toMovie
|
||||
@@ -31,10 +31,10 @@ import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class InMemoryMediaRepository @Inject constructor(
|
||||
class InMemoryLocalMediaRepository @Inject constructor(
|
||||
private val userSessionRepository: UserSessionRepository,
|
||||
private val jellyfinApiClient: JellyfinApiClient,
|
||||
) : MediaRepository {
|
||||
) : LocalMediaRepository {
|
||||
|
||||
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package hu.bbara.purefin.data.catalog
|
||||
|
||||
import hu.bbara.purefin.data.MediaRepository
|
||||
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
|
||||
@@ -20,9 +20,9 @@ import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class OfflineMediaRepository @Inject constructor(
|
||||
class OfflineLocalMediaRepository @Inject constructor(
|
||||
private val localDataSource: OfflineRoomMediaLocalDataSource,
|
||||
) : MediaRepository {
|
||||
) : LocalMediaRepository {
|
||||
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
|
||||
override val movies: StateFlow<Map<UUID, Movie>> = localDataSource.moviesFlow
|
||||
@@ -107,6 +107,36 @@ class JellyfinApiClient @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun searchBySearchTerm(searchTerm: String): List<BaseItemDto> = withContext(Dispatchers.IO) {
|
||||
logApiFailure("searchBySearchTerm") {
|
||||
if (!ensureConfigured()) {
|
||||
return@logApiFailure emptyList()
|
||||
}
|
||||
val response = api.itemsApi.getItems(
|
||||
userId = getUserId(),
|
||||
includeItemTypes = listOf(BaseItemKind.MOVIE, BaseItemKind.SERIES),
|
||||
searchTerm = searchTerm,
|
||||
)
|
||||
Log.d("searchBySearchTerm", response.content.toString())
|
||||
response.content.items
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun searchByGenre(genres: List<String>): List<BaseItemDto> = withContext(Dispatchers.IO) {
|
||||
logApiFailure("searchMovie") {
|
||||
if (!ensureConfigured()) {
|
||||
return@logApiFailure emptyList()
|
||||
}
|
||||
val response = api.itemsApi.getItems(
|
||||
userId = getUserId(),
|
||||
includeItemTypes = listOf(BaseItemKind.MOVIE, BaseItemKind.SERIES),
|
||||
genres = genres
|
||||
)
|
||||
Log.d("searchByGenre", response.content.toString())
|
||||
response.content.items
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getLibraries(): List<BaseItemDto> = withContext(Dispatchers.IO) {
|
||||
logApiFailure("getLibraries") {
|
||||
if (!ensureConfigured()) {
|
||||
|
||||
@@ -7,10 +7,10 @@ import dagger.hilt.components.SingletonComponent
|
||||
import hu.bbara.purefin.Offline
|
||||
import hu.bbara.purefin.Online
|
||||
import hu.bbara.purefin.data.HomeRepository
|
||||
import hu.bbara.purefin.data.MediaRepository
|
||||
import hu.bbara.purefin.data.LocalMediaRepository
|
||||
import hu.bbara.purefin.data.catalog.InMemoryAppContentRepository
|
||||
import hu.bbara.purefin.data.catalog.InMemoryMediaRepository
|
||||
import hu.bbara.purefin.data.catalog.OfflineMediaRepository
|
||||
import hu.bbara.purefin.data.catalog.InMemoryLocalMediaRepository
|
||||
import hu.bbara.purefin.data.catalog.OfflineLocalMediaRepository
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
@@ -18,11 +18,11 @@ abstract class MediaRepositoryModule {
|
||||
|
||||
@Binds
|
||||
@Online
|
||||
abstract fun bindOnlineRepository(impl: InMemoryMediaRepository): MediaRepository
|
||||
abstract fun bindOnlineRepository(impl: InMemoryLocalMediaRepository): LocalMediaRepository
|
||||
|
||||
@Binds
|
||||
@Offline
|
||||
abstract fun bindOfflineRepository(impl: OfflineMediaRepository): MediaRepository
|
||||
abstract fun bindOfflineRepository(impl: OfflineLocalMediaRepository): LocalMediaRepository
|
||||
|
||||
@Binds
|
||||
abstract fun bindHomeRepository(impl: InMemoryAppContentRepository): HomeRepository
|
||||
|
||||
Reference in New Issue
Block a user