From a3378e6080418e6ba9bab4d027d7f06373556217 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 3 Jul 2022 16:51:11 -0400 Subject: [PATCH] More domain model usage --- .../interactor/SyncChaptersWithSource.kt | 3 +- .../eu/kanade/domain/chapter/model/Chapter.kt | 30 ++++++------ .../eu/kanade/domain/manga/model/Manga.kt | 46 +++++++++++++------ .../tachiyomi/data/download/DownloadCache.kt | 2 +- .../data/download/DownloadManager.kt | 2 +- .../data/download/DownloadPendingDeleter.kt | 13 ++++-- .../data/download/DownloadProvider.kt | 2 +- .../tachiyomi/data/download/DownloadStore.kt | 5 +- .../tachiyomi/data/download/Downloader.kt | 2 +- .../tachiyomi/data/download/model/Download.kt | 5 +- .../data/download/model/DownloadQueue.kt | 2 +- .../data/library/LibraryUpdateService.kt | 2 +- .../data/notification/NotificationReceiver.kt | 5 +- .../tachiyomi/ui/library/LibraryPresenter.kt | 11 ++--- .../tachiyomi/ui/manga/MangaPresenter.kt | 8 ++-- .../tachiyomi/ui/reader/ReaderPresenter.kt | 2 +- .../ui/reader/loader/DownloadPageLoader.kt | 3 +- .../ui/recent/updates/UpdatesPresenter.kt | 5 +- 18 files changed, 80 insertions(+), 68 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt b/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt index 31c4187664..3a03227563 100644 --- a/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt +++ b/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt @@ -7,7 +7,6 @@ import eu.kanade.domain.chapter.model.toDbChapter import eu.kanade.domain.chapter.repository.ChapterRepository import eu.kanade.domain.manga.interactor.UpdateManga import eu.kanade.domain.manga.model.Manga -import eu.kanade.domain.manga.model.toDbManga import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.Source @@ -97,7 +96,7 @@ class SyncChaptersWithSource( } else { if (shouldUpdateDbChapter.await(dbChapter, chapter)) { if (dbChapter.name != chapter.name && downloadManager.isChapterDownloaded(dbChapter.name, dbChapter.scanlator, manga.title, manga.source)) { - downloadManager.renameChapter(source, manga.toDbManga(), dbChapter.toDbChapter(), chapter.toDbChapter()) + downloadManager.renameChapter(source, manga, dbChapter.toDbChapter(), chapter.toDbChapter()) } var toChangeChapter = dbChapter.copy( name = chapter.name, diff --git a/app/src/main/java/eu/kanade/domain/chapter/model/Chapter.kt b/app/src/main/java/eu/kanade/domain/chapter/model/Chapter.kt index ba67b69172..24da27348f 100644 --- a/app/src/main/java/eu/kanade/domain/chapter/model/Chapter.kt +++ b/app/src/main/java/eu/kanade/domain/chapter/model/Chapter.kt @@ -42,22 +42,20 @@ data class Chapter( } companion object { - fun create(): Chapter { - return Chapter( - id = -1, - mangaId = -1, - read = false, - bookmark = false, - lastPageRead = 0, - dateFetch = 0, - sourceOrder = 0, - url = "", - name = "", - dateUpload = -1, - chapterNumber = -1f, - scanlator = null, - ) - } + fun create() = Chapter( + id = -1, + mangaId = -1, + read = false, + bookmark = false, + lastPageRead = 0, + dateFetch = 0, + sourceOrder = 0, + url = "", + name = "", + dateUpload = -1, + chapterNumber = -1f, + scanlator = null, + ) } } diff --git a/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt b/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt index 9e9b732d3f..ac19dbcf83 100644 --- a/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt +++ b/app/src/main/java/eu/kanade/domain/manga/model/Manga.kt @@ -33,20 +33,6 @@ data class Manga( val initialized: Boolean, ) : Serializable { - fun toSManga(): SManga { - return SManga.create().also { - it.url = url - it.title = title - it.artist = artist - it.author = author - it.description = description - it.genre = genre.orEmpty().joinToString() - it.status = status.toInt() - it.thumbnail_url = thumbnailUrl - it.initialized = initialized - } - } - val sorting: Long get() = chapterFlags and CHAPTER_SORTING_MASK @@ -100,6 +86,18 @@ data class Manga( return chapterFlags and CHAPTER_SORT_DIR_MASK == CHAPTER_SORT_DESC } + fun toSManga(): SManga = SManga.create().also { + it.url = url + it.title = title + it.artist = artist + it.author = author + it.description = description + it.genre = genre.orEmpty().joinToString() + it.status = status.toInt() + it.thumbnail_url = thumbnailUrl + it.initialized = initialized + } + companion object { // Generic filter that does not filter anything const val SHOW_ALL = 0x00000000L @@ -128,6 +126,26 @@ data class Manga( const val CHAPTER_DISPLAY_NAME = 0x00000000L const val CHAPTER_DISPLAY_NUMBER = 0x00100000L const val CHAPTER_DISPLAY_MASK = 0x00100000L + + fun create() = Manga( + id = -1L, + url = "", + title = "", + source = -1L, + favorite = false, + lastUpdate = -1L, + dateAdded = -1L, + viewerFlags = -1L, + chapterFlags = -1L, + coverLastModified = -1L, + artist = null, + author = null, + description = null, + genre = null, + status = 0L, + thumbnailUrl = null, + initialized = false, + ) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt index fee03fa1cd..d96bfe05ad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt @@ -3,8 +3,8 @@ package eu.kanade.tachiyomi.data.download import android.content.Context import androidx.core.net.toUri import com.hippo.unifile.UniFile +import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.data.database.models.Chapter -import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.source.SourceManager import kotlinx.coroutines.flow.onEach diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index 74e337e480..6ca9be9e8e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -4,9 +4,9 @@ import android.content.Context import com.hippo.unifile.UniFile import com.jakewharton.rxrelay.BehaviorRelay import eu.kanade.domain.category.interactor.GetCategories +import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Chapter -import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.download.model.DownloadQueue import eu.kanade.tachiyomi.data.preference.PreferencesHelper diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadPendingDeleter.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadPendingDeleter.kt index 57c78e5f17..945e57ca8f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadPendingDeleter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadPendingDeleter.kt @@ -2,8 +2,8 @@ package eu.kanade.tachiyomi.data.download import android.content.Context import androidx.core.content.edit +import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.data.database.models.Chapter -import eu.kanade.tachiyomi.data.database.models.Manga import kotlinx.serialization.Serializable import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString @@ -155,7 +155,7 @@ class DownloadPendingDeleter(context: Context) { * Returns a manga entry from a manga model. */ private fun Manga.toEntry(): MangaEntry { - return MangaEntry(id!!, url, title, source) + return MangaEntry(id, url, title, source) } /** @@ -169,9 +169,12 @@ class DownloadPendingDeleter(context: Context) { * Returns a manga model from a manga entry. */ private fun MangaEntry.toModel(): Manga { - return Manga.create(url, title, source).also { - it.id = id - } + return Manga.create().copy( + url = url, + title = title, + source = source, + id = id, + ) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt index 9aef158341..10ac1b9142 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt @@ -3,9 +3,9 @@ package eu.kanade.tachiyomi.data.download import android.content.Context import androidx.core.net.toUri import com.hippo.unifile.UniFile +import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Chapter -import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.util.storage.DiskUtil diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt index 9c92fd0549..19a4f45c90 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt @@ -5,8 +5,7 @@ import androidx.core.content.edit import eu.kanade.domain.chapter.interactor.GetChapter import eu.kanade.domain.chapter.model.toDbChapter import eu.kanade.domain.manga.interactor.GetManga -import eu.kanade.domain.manga.model.toDbManga -import eu.kanade.tachiyomi.data.database.models.Manga +import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.online.HttpSource @@ -96,7 +95,7 @@ class DownloadStore( val cachedManga = mutableMapOf() for ((mangaId, chapterId) in objs) { val manga = cachedManga.getOrPut(mangaId) { - runBlocking { getManga.await(mangaId)?.toDbManga() } + runBlocking { getManga.await(mangaId) } } ?: continue val source = sourceManager.get(manga.source) as? HttpSource ?: continue val chapter = runBlocking { getChapter.await(chapterId) }?.toDbChapter() ?: continue diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index 6ff8944423..9ad7f93558 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -5,10 +5,10 @@ import android.webkit.MimeTypeMap import com.hippo.unifile.UniFile import com.jakewharton.rxrelay.BehaviorRelay import com.jakewharton.rxrelay.PublishRelay +import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.cache.ChapterCache import eu.kanade.tachiyomi.data.database.models.Chapter -import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.download.model.DownloadQueue import eu.kanade.tachiyomi.data.library.LibraryUpdateNotifier diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt index 0ea7a63330..d632bafc41 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt @@ -3,9 +3,8 @@ package eu.kanade.tachiyomi.data.download.model import eu.kanade.domain.chapter.interactor.GetChapter import eu.kanade.domain.chapter.model.toDbChapter import eu.kanade.domain.manga.interactor.GetManga -import eu.kanade.domain.manga.model.toDbManga +import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.data.database.models.Chapter -import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.online.HttpSource @@ -76,7 +75,7 @@ data class Download( val manga = getManga.await(chapter.mangaId) ?: return null val source = sourceManager.get(manga.source) as? HttpSource ?: return null - return Download(source, manga.toDbManga(), chapter.toDbChapter()) + return Download(source, manga, chapter.toDbChapter()) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt index 4b7b623c2e..33cc2d52dc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/DownloadQueue.kt @@ -1,8 +1,8 @@ package eu.kanade.tachiyomi.data.download.model import com.jakewharton.rxrelay.PublishRelay +import eu.kanade.domain.manga.model.Manga import eu.kanade.tachiyomi.data.database.models.Chapter -import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.DownloadStore import eu.kanade.tachiyomi.source.model.Page import rx.Observable diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index bb370c7f4e..b361afd0e5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -416,7 +416,7 @@ class LibraryUpdateService( private fun downloadChapters(manga: Manga, chapters: List) { // We don't want to start downloading while the library is updating, because websites // may don't like it and they could ban the user. - downloadManager.downloadChapters(manga, chapters, false) + downloadManager.downloadChapters(manga.toDomainManga()!!, chapters, false) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt index a64a6a34fd..26d0a31798 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt @@ -14,7 +14,6 @@ import eu.kanade.domain.chapter.model.toChapterUpdate import eu.kanade.domain.chapter.model.toDbChapter import eu.kanade.domain.manga.interactor.GetManga import eu.kanade.domain.manga.model.Manga -import eu.kanade.domain.manga.model.toDbManga import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.backup.BackupRestoreService import eu.kanade.tachiyomi.data.download.DownloadManager @@ -252,7 +251,7 @@ class NotificationReceiver : BroadcastReceiver() { if (manga != null) { val source = sourceManager.get(manga.source) if (source != null) { - downloadManager.deleteChapters(listOf(it.toDbChapter()), manga.toDbManga(), source) + downloadManager.deleteChapters(listOf(it.toDbChapter()), manga, source) } } } @@ -270,7 +269,7 @@ class NotificationReceiver : BroadcastReceiver() { */ private fun downloadChapters(chapterUrls: Array, mangaId: Long) { launchIO { - val manga = getManga.await(mangaId)?.toDbManga() + val manga = getManga.await(mangaId) val chapters = chapterUrls.mapNotNull { getChapter.await(it, mangaId)?.toDbChapter() } if (manga != null && chapters.isNotEmpty()) { downloadManager.downloadChapters(manga, chapters) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index dcb5ed42d8..9feb5461b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -17,7 +17,6 @@ import eu.kanade.domain.manga.interactor.UpdateManga import eu.kanade.domain.manga.model.Manga import eu.kanade.domain.manga.model.MangaUpdate import eu.kanade.domain.manga.model.isLocal -import eu.kanade.domain.manga.model.toDbManga import eu.kanade.domain.track.interactor.GetTracks import eu.kanade.tachiyomi.data.cache.CoverCache import eu.kanade.tachiyomi.data.database.models.toDomainManga @@ -154,7 +153,7 @@ class LibraryPresenter( val isDownloaded = when { item.manga.toDomainManga()!!.isLocal() -> true item.downloadCount != -1 -> item.downloadCount > 0 - else -> downloadManager.getDownloadCount(item.manga) > 0 + else -> downloadManager.getDownloadCount(item.manga.toDomainManga()!!) > 0 } return@downloaded if (downloadedOnly || filterDownloaded == State.INCLUDE.value) isDownloaded @@ -236,7 +235,7 @@ class LibraryPresenter( for ((_, itemList) in map) { for (item in itemList) { item.downloadCount = if (showDownloadBadges) { - downloadManager.getDownloadCount(item.manga) + downloadManager.getDownloadCount(item.manga.toDomainManga()!!) } else { // Unset download count if not enabled -1 @@ -521,7 +520,7 @@ class LibraryPresenter( .filter { !it.read } .map { it.toDbChapter() } - downloadManager.downloadChapters(manga.toDbManga(), chapters) + downloadManager.downloadChapters(manga, chapters) } } } @@ -555,7 +554,7 @@ class LibraryPresenter( private fun deleteChapters(manga: Manga, chapters: List) { sourceManager.get(manga.source)?.let { source -> - downloadManager.deleteChapters(chapters.map { it.toDbChapter() }, manga.toDbManga(), source) + downloadManager.deleteChapters(chapters.map { it.toDbChapter() }, manga, source) } } @@ -585,7 +584,7 @@ class LibraryPresenter( mangaToDelete.forEach { manga -> val source = sourceManager.get(manga.source) as? HttpSource if (source != null) { - downloadManager.deleteManga(manga, source) + downloadManager.deleteManga(manga.toDomainManga()!!, source) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index 9bd46941bb..64da8563fa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -305,7 +305,7 @@ class MangaPresenter( */ fun hasDownloads(): Boolean { val manga = successState?.manga ?: return false - return downloadManager.getDownloadCount(manga.toDbManga()) > 0 + return downloadManager.getDownloadCount(manga) > 0 } /** @@ -313,7 +313,7 @@ class MangaPresenter( */ fun deleteDownloads() { val state = successState ?: return - downloadManager.deleteManga(state.manga.toDbManga(), state.source) + downloadManager.deleteManga(state.manga, state.source) } /** @@ -541,7 +541,7 @@ class MangaPresenter( */ fun downloadChapters(chapters: List) { val manga = successState?.manga ?: return - downloadManager.downloadChapters(manga.toDbManga(), chapters.map { it.toDbChapter() }) + downloadManager.downloadChapters(manga, chapters.map { it.toDbChapter() }) } /** @@ -567,7 +567,7 @@ class MangaPresenter( try { updateSuccessState { successState -> val deletedIds = downloadManager - .deleteChapters(chapters2, successState.manga.toDbManga(), successState.source) + .deleteChapters(chapters2, successState.manga, successState.source) .map { it.id } val deletedChapters = successState.chapters.filter { deletedIds.contains(it.chapter.id) } if (deletedChapters.isEmpty()) return@updateSuccessState successState diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 1f7cbaf005..adf0d79618 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -804,7 +804,7 @@ class ReaderPresenter( val manga = manga ?: return launchIO { - downloadManager.enqueueDeleteChapters(listOf(chapter.chapter), manga) + downloadManager.enqueueDeleteChapters(listOf(chapter.chapter), manga.toDomainManga()!!) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt index 4fadbdc9ac..0d01fde249 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt @@ -4,7 +4,6 @@ import android.app.Application import android.net.Uri import com.hippo.unifile.UniFile import eu.kanade.domain.manga.model.Manga -import eu.kanade.domain.manga.model.toDbManga import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.model.Page @@ -46,7 +45,7 @@ class DownloadPageLoader( } private fun getPagesFromDirectory(): Observable> { - return downloadManager.buildPageList(source, manga.toDbManga(), chapter.chapter) + return downloadManager.buildPageList(source, manga, chapter.chapter) .map { pages -> pages.map { page -> ReaderPage(page.index, page.url, page.imageUrl) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt index 3318177812..3f6d70cf67 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt @@ -8,7 +8,6 @@ import eu.kanade.domain.chapter.model.Chapter import eu.kanade.domain.chapter.model.ChapterUpdate import eu.kanade.domain.chapter.model.toDbChapter import eu.kanade.domain.manga.model.Manga -import eu.kanade.domain.manga.model.toDbManga import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.preference.PreferencesHelper @@ -219,7 +218,7 @@ class UpdatesPresenter : BasePresenter() { * @param items list of recent chapters seleted. */ fun downloadChapters(items: List) { - items.forEach { downloadManager.downloadChapters(it.manga.toDbManga(), listOf(it.chapter.toDbChapter())) } + items.forEach { downloadManager.downloadChapters(it.manga, listOf(it.chapter.toDbChapter())) } } /** @@ -230,7 +229,7 @@ class UpdatesPresenter : BasePresenter() { private fun deleteChaptersInternal(chapterItems: List) { val itemsByManga = chapterItems.groupBy { it.manga.id } for ((_, items) in itemsByManga) { - val manga = items.first().manga.toDbManga() + val manga = items.first().manga val source = sourceManager.get(manga.source) ?: continue val chapters = items.map { it.chapter.toDbChapter() }