Ensure suggested items are for the current user (#47)

Fixes #46

Makes sure that the suggested items fetched on Movies & TV Shows
recommended tab are for the current user which should respect content
restrictions and other permissions.
This commit is contained in:
damontecres 2025-10-20 19:10:36 -04:00 committed by GitHub
parent 77aaa87126
commit e7a85f4f5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.github.damontecres.wholphin.data.ServerRepository
import com.github.damontecres.wholphin.data.model.BaseItem import com.github.damontecres.wholphin.data.model.BaseItem
import com.github.damontecres.wholphin.preferences.UserPreferences import com.github.damontecres.wholphin.preferences.UserPreferences
import com.github.damontecres.wholphin.ui.OneTimeLaunchedEffect import com.github.damontecres.wholphin.ui.OneTimeLaunchedEffect
@ -41,6 +42,7 @@ class RecommendedMovieViewModel
@Inject @Inject
constructor( constructor(
private val api: ApiClient, private val api: ApiClient,
private val serverRepository: ServerRepository,
) : ViewModel() { ) : ViewModel() {
val loading = MutableLiveData<LoadingState>(LoadingState.Loading) val loading = MutableLiveData<LoadingState>(LoadingState.Loading)
val rows = MutableLiveData<List<HomeRow>>() val rows = MutableLiveData<List<HomeRow>>()
@ -88,6 +90,7 @@ class RecommendedMovieViewModel
val suggestionsRequest = val suggestionsRequest =
GetSuggestionsRequest( GetSuggestionsRequest(
userId = serverRepository.currentUser?.id,
type = listOf(BaseItemKind.MOVIE), type = listOf(BaseItemKind.MOVIE),
) )
val suggestedItems = ApiRequestPager(api, suggestionsRequest, GetSuggestionsRequestHandler, viewModelScope) val suggestedItems = ApiRequestPager(api, suggestionsRequest, GetSuggestionsRequestHandler, viewModelScope)

View file

@ -8,6 +8,7 @@ import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.github.damontecres.wholphin.data.ServerRepository
import com.github.damontecres.wholphin.data.model.BaseItem import com.github.damontecres.wholphin.data.model.BaseItem
import com.github.damontecres.wholphin.preferences.UserPreferences import com.github.damontecres.wholphin.preferences.UserPreferences
import com.github.damontecres.wholphin.ui.OneTimeLaunchedEffect import com.github.damontecres.wholphin.ui.OneTimeLaunchedEffect
@ -43,6 +44,7 @@ class RecommendedTvShowViewModel
@Inject @Inject
constructor( constructor(
private val api: ApiClient, private val api: ApiClient,
private val serverRepository: ServerRepository,
) : ViewModel() { ) : ViewModel() {
val loading = MutableLiveData<LoadingState>(LoadingState.Loading) val loading = MutableLiveData<LoadingState>(LoadingState.Loading)
val rows = MutableLiveData<List<HomeRow>>() val rows = MutableLiveData<List<HomeRow>>()
@ -98,6 +100,7 @@ class RecommendedTvShowViewModel
val suggestionsRequest = val suggestionsRequest =
GetSuggestionsRequest( GetSuggestionsRequest(
userId = serverRepository.currentUser?.id,
type = listOf(BaseItemKind.SERIES), type = listOf(BaseItemKind.SERIES),
) )
val suggestedItems = ApiRequestPager(api, suggestionsRequest, GetSuggestionsRequestHandler, viewModelScope) val suggestedItems = ApiRequestPager(api, suggestionsRequest, GetSuggestionsRequestHandler, viewModelScope)