mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-14 21:18:56 +01:00
Always remove manga title from if it prefixes chapter names (related to #6913)
This commit is contained in:
@@ -901,7 +901,7 @@ class MangaController :
|
||||
chaptersHeader.setNumChapters(chapters.size)
|
||||
|
||||
val adapter = chaptersAdapter ?: return
|
||||
adapter.updateDataSet(chapters)
|
||||
adapter.updateDataSet(presenter.cleanChapterNames(chapters))
|
||||
|
||||
if (selectedChapters.isNotEmpty()) {
|
||||
adapter.clearSelection() // we need to start from a clean state, index may have changed
|
||||
|
||||
@@ -431,6 +431,17 @@ class MangaPresenter(
|
||||
}
|
||||
}
|
||||
|
||||
fun cleanChapterNames(chapters: List<ChapterItem>): List<ChapterItem> {
|
||||
chapters.forEach {
|
||||
it.name = it.name
|
||||
.trim()
|
||||
.removePrefix(manga.title)
|
||||
.trim(*CHAPTER_TRIM_CHARS)
|
||||
}
|
||||
|
||||
return chapters
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the UI after applying the filters.
|
||||
*/
|
||||
@@ -852,3 +863,38 @@ class MangaPresenter(
|
||||
|
||||
// Track sheet - end
|
||||
}
|
||||
|
||||
private val CHAPTER_TRIM_CHARS = arrayOf(
|
||||
// Whitespace
|
||||
' ',
|
||||
'\u0009',
|
||||
'\u000A',
|
||||
'\u000B',
|
||||
'\u000C',
|
||||
'\u000D',
|
||||
'\u0020',
|
||||
'\u0085',
|
||||
'\u00A0',
|
||||
'\u1680',
|
||||
'\u2000',
|
||||
'\u2001',
|
||||
'\u2002',
|
||||
'\u2003',
|
||||
'\u2004',
|
||||
'\u2005',
|
||||
'\u2006',
|
||||
'\u2007',
|
||||
'\u2008',
|
||||
'\u2009',
|
||||
'\u200A',
|
||||
'\u2028',
|
||||
'\u2029',
|
||||
'\u202F',
|
||||
'\u205F',
|
||||
'\u3000',
|
||||
// Separators
|
||||
'-',
|
||||
'_',
|
||||
',',
|
||||
':',
|
||||
).toCharArray()
|
||||
|
||||
Reference in New Issue
Block a user