From 0871208023b46452fbf26f9baebea82cecb33f39 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 15 Jun 2023 22:16:31 -0400 Subject: [PATCH] Avoid crash when trying to open random entry but categories are still loading Fixes #9610 --- .../java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt index cbc7bfbea..fa982d322 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt @@ -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)