mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-08-05 11:01:37 +00:00
fix(library): preserve leading articles in title sorting for natural alphabetical order
This commit is contained in:
parent
88d3cbdfac
commit
cfa49a2cda
2 changed files with 3 additions and 7 deletions
|
|
@ -227,12 +227,8 @@ private val LibraryDisplaySettingsJson = Json {
|
|||
encodeDefaults = true
|
||||
}
|
||||
|
||||
private val LeadingLibraryTitleArticle = Regex("^(the|an|a)\\s+", RegexOption.IGNORE_CASE)
|
||||
|
||||
private fun libraryTitleSortKey(item: LibraryItem): String =
|
||||
libraryTitleTieBreakKey(item)
|
||||
.trim()
|
||||
.replace(LeadingLibraryTitleArticle, "")
|
||||
|
||||
private fun libraryTitleTieBreakKey(item: LibraryItem): String =
|
||||
item.name
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class LibraryDisplaySettingsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `title sorting ignores leading English articles`() {
|
||||
fun `title sorting preserves leading articles for literal alphabetical order`() {
|
||||
val input = listOf(
|
||||
item("batman", name = "The Batman"),
|
||||
item("arrival", name = "Arrival"),
|
||||
|
|
@ -59,11 +59,11 @@ class LibraryDisplaySettingsTest {
|
|||
)
|
||||
|
||||
assertEquals(
|
||||
listOf("arrival", "batman", "quiet"),
|
||||
listOf("quiet", "arrival", "batman"),
|
||||
sortLibraryItems(input, LibrarySortOption.TITLE_ASC, LibrarySourceMode.LOCAL).map { it.id },
|
||||
)
|
||||
assertEquals(
|
||||
listOf("quiet", "batman", "arrival"),
|
||||
listOf("batman", "arrival", "quiet"),
|
||||
sortLibraryItems(input, LibrarySortOption.TITLE_DESC, LibrarySourceMode.LOCAL).map { it.id },
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue