Fix download status not updating in recents

This commit is contained in:
Jays2Kings 2023-03-02 14:15:04 -05:00
parent 991d46c8aa
commit 5e44436361
3 changed files with 9 additions and 5 deletions

View file

@ -9,8 +9,6 @@ package eu.kanade.tachiyomi.data.database.models
*/ */
data class MangaChapterHistory(val manga: Manga, val chapter: Chapter, val history: History, var extraChapters: List<Chapter> = emptyList()) { data class MangaChapterHistory(val manga: Manga, val chapter: Chapter, val history: History, var extraChapters: List<Chapter> = emptyList()) {
val allChapters: List<Chapter>
get() = listOf(chapter) + extraChapters
companion object { companion object {
fun createBlank() = MangaChapterHistory(MangaImpl(), ChapterImpl(), HistoryImpl()) fun createBlank() = MangaChapterHistory(MangaImpl(), ChapterImpl(), HistoryImpl())
} }

View file

@ -62,7 +62,7 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
fun getItemByChapterId(id: Long): RecentMangaItem? { fun getItemByChapterId(id: Long): RecentMangaItem? {
return currentItems.find { return currentItems.find {
val item = (it as? RecentMangaItem) ?: return@find false val item = (it as? RecentMangaItem) ?: return@find false
return@find id in item.mch.allChapters.map { ch -> ch.id } return@find id == item.chapter.id || id in item.mch.extraChapters.map { ch -> ch.id }
} as? RecentMangaItem } as? RecentMangaItem
} }

View file

@ -447,7 +447,10 @@ class RecentsPresenter(
} }
override fun updateDownload(download: Download) { override fun updateDownload(download: Download) {
recentItems.find { download.chapter.id in it.mch.allChapters.map { ch -> ch.id } }?.apply { recentItems.find {
download.chapter.id == it.chapter.id ||
download.chapter.id in it.mch.extraChapters.map { ch -> ch.id }
}?.apply {
if (chapter.id != download.chapter.id) { if (chapter.id != download.chapter.id) {
val downloadInfo = downloadInfo.find { it.chapterId == download.chapter.id } val downloadInfo = downloadInfo.find { it.chapterId == download.chapter.id }
?: return@apply ?: return@apply
@ -501,7 +504,10 @@ class RecentsPresenter(
downloadManager.deleteChapters(listOf(chapter), manga, source, true) downloadManager.deleteChapters(listOf(chapter), manga, source, true)
} }
if (update) { if (update) {
val item = recentItems.find { chapter.id in it.mch.allChapters.map { ch -> ch.id } } ?: return val item = recentItems.find {
chapter.id == it.chapter.id ||
chapter.id in it.mch.extraChapters.map { ch -> ch.id }
} ?: return
item.apply { item.apply {
if (chapter.id != item.chapter.id) { if (chapter.id != item.chapter.id) {
val extraChapter = mch.extraChapters.find { it.id == chapter.id } ?: return@apply val extraChapter = mch.extraChapters.find { it.id == chapter.id } ?: return@apply