Avoid crash when trying to open random entry but categories are still loading

Fixes #9610
This commit is contained in:
arkon 2023-06-15 22:16:31 -04:00
parent ee95c1439f
commit 0871208023

View file

@ -527,6 +527,8 @@ class LibraryScreenModel(
}
suspend fun getRandomLibraryItemForCurrentCategory(): LibraryItem? {
if (state.value.categories.isEmpty()) return null
return withIOContext {
state.value
.getLibraryItemsByCategoryId(state.value.categories[activeCategoryIndex].id)