mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Fix discover not showing
This commit is contained in:
parent
8ff530a4f9
commit
12590d7221
2 changed files with 23 additions and 3 deletions
|
|
@ -10,6 +10,7 @@ import com.github.damontecres.wholphin.ui.nav.NavDrawerItem
|
|||
import com.github.damontecres.wholphin.ui.nav.ServerNavDrawerItem
|
||||
import com.github.damontecres.wholphin.util.supportedCollectionTypes
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.flow.first
|
||||
import org.jellyfin.sdk.api.client.ApiClient
|
||||
import org.jellyfin.sdk.api.client.extensions.liveTvApi
|
||||
import org.jellyfin.sdk.api.client.extensions.userViewsApi
|
||||
|
|
@ -49,7 +50,7 @@ class NavDrawerItemRepository
|
|||
}
|
||||
|
||||
val builtins =
|
||||
if (seerrServerRepository.active()) {
|
||||
if (seerrServerRepository.active.first()) {
|
||||
listOf(NavDrawerItem.Favorites, NavDrawerItem.Discover)
|
||||
} else {
|
||||
listOf(NavDrawerItem.Favorites)
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ import com.github.damontecres.wholphin.preferences.AppThemeColors
|
|||
import com.github.damontecres.wholphin.preferences.UserPreferences
|
||||
import com.github.damontecres.wholphin.services.BackdropService
|
||||
import com.github.damontecres.wholphin.services.NavigationManager
|
||||
import com.github.damontecres.wholphin.services.SeerrServerRepository
|
||||
import com.github.damontecres.wholphin.services.SetupDestination
|
||||
import com.github.damontecres.wholphin.services.SetupNavigationManager
|
||||
import com.github.damontecres.wholphin.ui.FontAwesome
|
||||
|
|
@ -94,6 +95,8 @@ import com.github.damontecres.wholphin.util.ExceptionHandler
|
|||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jellyfin.sdk.model.api.CollectionType
|
||||
|
|
@ -109,6 +112,7 @@ class NavDrawerViewModel
|
|||
val navigationManager: NavigationManager,
|
||||
val setupNavigationManager: SetupNavigationManager,
|
||||
val backdropService: BackdropService,
|
||||
private val seerrServerRepository: SeerrServerRepository,
|
||||
) : ViewModel() {
|
||||
// private var all: List<NavDrawerItem>? = null
|
||||
val moreLibraries = MutableLiveData<List<NavDrawerItem>>(null)
|
||||
|
|
@ -116,6 +120,13 @@ class NavDrawerViewModel
|
|||
val selectedIndex = MutableLiveData(-1)
|
||||
val showMore = MutableLiveData(false)
|
||||
|
||||
init {
|
||||
seerrServerRepository.active
|
||||
.onEach {
|
||||
init()
|
||||
}.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
fun init() {
|
||||
viewModelScope.launchIO {
|
||||
val all = navDrawerItemRepository.getNavDrawerItems()
|
||||
|
|
@ -128,11 +139,19 @@ class NavDrawerViewModel
|
|||
this@NavDrawerViewModel.libraries.value = libraries
|
||||
}
|
||||
val asDestinations =
|
||||
(libraries + listOf(NavDrawerItem.More) + moreLibraries).map {
|
||||
(
|
||||
libraries +
|
||||
listOf(
|
||||
NavDrawerItem.More,
|
||||
NavDrawerItem.Discover,
|
||||
) + moreLibraries
|
||||
).map {
|
||||
if (it is ServerNavDrawerItem) {
|
||||
it.destination
|
||||
} else if (it is NavDrawerItem.Favorites) {
|
||||
Destination.Favorites
|
||||
} else if (it is NavDrawerItem.Discover) {
|
||||
Destination.Discover
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
@ -155,7 +174,7 @@ class NavDrawerViewModel
|
|||
null
|
||||
}
|
||||
}
|
||||
// Timber.v("Found $index => $key")
|
||||
Timber.v("Found $index => $key")
|
||||
if (index != null) {
|
||||
selectedIndex.setValueOnMain(index)
|
||||
break
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue