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