mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-11-06 02:40:58 +01:00
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:
parent
39c030c1d5
commit
a350fa2017
16 changed files with 211 additions and 76 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue