Also search in category descriptions

this is currently limited to the current locale, so requires translations to exist for that.
This commit is contained in:
Torsten Grote
2026-04-24 08:55:16 -03:00
parent 16b4021b30
commit 0bd7f0cc6f
2 changed files with 9 additions and 3 deletions

View File

@@ -58,7 +58,11 @@ constructor(
db.getRepositoryDao().getLiveCategories().asFlow().map { categories ->
categories
.map { category ->
CategoryItem(id = category.id, name = category.getName(localeList) ?: "Unknown Category")
CategoryItem(
id = category.id,
name = category.getName(localeList) ?: "Unknown Category",
description = category.getDescription(localeList),
)
}
.sortedWith { c1, c2 -> collator.compare(c1.name, c2.name) }
}
@@ -113,7 +117,9 @@ constructor(
val timedCategories = measureTimedValue {
categories.first().filter {
// normalization removed diacritics, so searches without them work
it.name.normalize().contains(sanitized.normalize(), ignoreCase = true)
val normalized = sanitized.normalize()
it.name.normalize().contains(normalized, ignoreCase = true) ||
(it.description?.normalize()?.contains(normalized, ignoreCase = true) ?: false)
}
}
_searchResults.value = SearchResults(timedApps.value, timedCategories.value)

View File

@@ -74,7 +74,7 @@ import androidx.compose.material.icons.filled.Wallpaper
import androidx.compose.material.icons.filled.WbSunny
import androidx.compose.ui.graphics.vector.ImageVector
data class CategoryItem(val id: String, val name: String) {
data class CategoryItem(val id: String, val name: String, val description: String? = null) {
val imageVector: ImageVector
get() =
when (id) {