Improvements to "Add to playlist" dialog (#1706)

## Description
Fixes & improves the "Add to playlist" dialog:
- Added searching by name
- Playlists are sorted by recently updated
- No longer filters by media type
- Filters based on user's permission for the playlists

The behavior is now consistent with the web UI's list except for the
sort

### Related issues
Should fix #1124

### Testing
Emulator testing

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-07-16 11:35:48 -04:00 • committed by GitHub
parent 39c030c1d5
commit a350fa2017
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 211 additions and 76 deletions

View file

@ -10,14 +10,20 @@ object SearchRelevance {
fun score(
item: BaseItem,
query: String,
): Int = score(item.name, item.type, query)
fun score(
name: String?,
type: BaseItemKind,
query: String,
): Int {
val name = item.name?.lowercase(Locale.getDefault()) ?: return Int.MAX_VALUE
val name = name?.lowercase(Locale.getDefault()) ?: return Int.MAX_VALUE
val q = query.lowercase(Locale.getDefault())
REGEX_PATTERN.find(query)?.let { match ->
val pattern = match.groupValues[1]
val caseInsensitive = match.groupValues[2] == "i"
return regexScore(item.name ?: "", pattern, caseInsensitive) + typeBonus(item.type)
return regexScore(name, pattern, caseInsensitive) + typeBonus(type)
}
return when {
@ -26,7 +32,7 @@ object SearchRelevance {
name.contains(" $q") -> 200
name.contains(q) -> 300
else -> fuzzyScore(name, q)
} + typeBonus(item.type)
} + typeBonus(type)
}
private fun regexScore(