Fix infinite loading when user library is empty (#7602)

- If no manga in library add default category this to remove loading state

(cherry picked from commit 164de67a56095335119b63b3b17abab5007703f8)
This commit is contained in:
Andreas 2022-07-24 18:43:33 +02:00 committed by Jobobby04
parent 051a9f33df
commit 4b03d3559f

View File

@ -572,14 +572,14 @@ class LibraryPresenter(
*/
private fun getLibraryObservable(): Observable<Library> {
return combine(getCategoriesFlow(), getLibraryMangasFlow()) { dbCategories, libraryManga ->
val categories = if (libraryManga.containsKey(0)) {
val categories = if (libraryManga.containsKey(0) || libraryManga.isEmpty()) {
arrayListOf(Category.default(context)) + dbCategories
} else {
dbCategories
}
libraryManga.forEach { (categoryId, libraryManga) ->
val category = categories.first { category -> category.id == categoryId.toLong() }
val category = categories.first { category -> category.id == categoryId }
libraryManga.forEach { libraryItem ->
libraryItem.displayMode = category.displayMode
}