Fix Crash while trying to search in Settings (#6397)

* Fix Crash while trying to search in Settings

* Use already provided categories
This commit is contained in:
FourTOne5 2022-01-01 00:21:05 +06:00 committed by GitHub
parent 6a00658119
commit fc3a200a63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -230,9 +230,6 @@ class SettingsLibraryController : SettingsController() {
} }
fun updateSummary() { fun updateSummary() {
val dbCategories = db.getCategories().executeAsBlocking()
val allCategories = listOf(Category.createDefault(activity!!)) + dbCategories
val includedCategories = preferences.libraryUpdateCategories().get() val includedCategories = preferences.libraryUpdateCategories().get()
.mapNotNull { id -> categories.find { it.id == id.toInt() } } .mapNotNull { id -> categories.find { it.id == id.toInt() } }
.sortedBy { it.order } .sortedBy { it.order }
@ -244,14 +241,14 @@ class SettingsLibraryController : SettingsController() {
val includedItemsText = if (includedCategories.isEmpty()) { val includedItemsText = if (includedCategories.isEmpty()) {
context.getString(R.string.none) context.getString(R.string.none)
} else { } else {
if (includedCategories.size == allCategories.size) context.getString(R.string.all) if (includedCategories.size == categories.size) context.getString(R.string.all)
else includedCategories.joinToString { it.name } else includedCategories.joinToString { it.name }
} }
val excludedItemsText = if (excludedCategories.isEmpty()) { val excludedItemsText = if (excludedCategories.isEmpty()) {
context.getString(R.string.none) context.getString(R.string.none)
} else { } else {
if (excludedCategories.size == allCategories.size) context.getString(R.string.all) if (excludedCategories.size == categories.size) context.getString(R.string.all)
else excludedCategories.joinToString { it.name } else excludedCategories.joinToString { it.name }
} }