safe-guard some edge-cases where chapters are duplicated some how on a merged entry (#311)

This commit is contained in:
Tran M. Cuong 2024-08-28 18:36:52 +07:00 committed by GitHub
parent 37a817e8f8
commit 9a12a904ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -1204,7 +1204,9 @@ private fun LazyListScope.sharedChapterItems(
items = chapters,
key = { item ->
when (item) {
is ChapterList.MissingCount -> "missing-count-${item.id}"
// KMK: using hashcode to prevent edge-cases where the missing count might duplicate,
// especially on merged manga
is ChapterList.MissingCount -> "missing-count-${item.hashCode()}"
is ChapterList.Item -> "chapter-${item.id}"
}
},

View file

@ -1832,6 +1832,10 @@ class MangaScreenModel(
val processedChapters by lazy {
chapters.applyFilters(manga).toList()
// KMK -->
// safe-guard some edge-cases where chapters are duplicated some how on a merged entry
.distinctBy { it.id }
// KMK <--
}
val isAnySelected by lazy {