Merge pull request #5602 from Bnyro/master

fix: homepage not loading when trends disabled
This commit is contained in:
Bnyro 2024-02-05 16:32:18 +01:00 committed by GitHub
commit b2d2bc7c88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,26 +26,21 @@ import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
class HomeViewModel: ViewModel() { class HomeViewModel: ViewModel() {
private val hideWatched get() = PreferenceHelper.getBoolean(HIDE_WATCHED_FROM_FEED, false) private val hideWatched get() = PreferenceHelper.getBoolean(HIDE_WATCHED_FROM_FEED, false)
val trending: MutableLiveData<List<StreamItem>> = MutableLiveData(null) val trending: MutableLiveData<List<StreamItem>> = MutableLiveData(null)
val feed: MutableLiveData<List<StreamItem>> = MutableLiveData(null) val feed: MutableLiveData<List<StreamItem>> = MutableLiveData(null)
val bookmarks: MutableLiveData<List<PlaylistBookmark>> = MutableLiveData(null) val bookmarks: MutableLiveData<List<PlaylistBookmark>> = MutableLiveData(null)
val playlists: MutableLiveData<List<Playlists>> = MutableLiveData(null) val playlists: MutableLiveData<List<Playlists>> = MutableLiveData(null)
val continueWatching: MutableLiveData<List<StreamItem>> = MutableLiveData(null) val continueWatching: MutableLiveData<List<StreamItem>> = MutableLiveData(null)
val isLoading: MutableLiveData<Boolean> = MutableLiveData(true) val isLoading: MutableLiveData<Boolean> = MutableLiveData(true)
val loadedSuccessfully: MutableLiveData<Boolean> = MutableLiveData(false) val loadedSuccessfully: MutableLiveData<Boolean> = MutableLiveData(false)
private val sections get() = listOf(trending, feed, bookmarks, playlists, continueWatching)
private var loadHomeJob: Job? = null private var loadHomeJob: Job? = null
fun loadHomeFeed( fun loadHomeFeed(
@ -66,7 +61,7 @@ class HomeViewModel: ViewModel() {
async { if (visibleItems.contains(PLAYLISTS)) loadPlaylists() }, async { if (visibleItems.contains(PLAYLISTS)) loadPlaylists() },
async { if (visibleItems.contains(WATCHING)) loadVideosToContinueWatching() } async { if (visibleItems.contains(WATCHING)) loadVideosToContinueWatching() }
) )
loadedSuccessfully.value = trending.value.isNullOrEmpty() == false loadedSuccessfully.value = sections.any { !it.value.isNullOrEmpty() }
isLoading.value = false isLoading.value = false
} }