mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Merge pull request #5602 from Bnyro/master
fix: homepage not loading when trends disabled
This commit is contained in:
commit
b2d2bc7c88
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user