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

Fixes #9610

(cherry picked from commit 0871208023b46452fbf26f9baebea82cecb33f39)
This commit is contained in:
arkon 2023-06-15 22:16:31 -04:00 committed by Jobobby04
parent bf0dee8d03
commit 2f360a3fd7

View File

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