More domain model usage
This commit is contained in:
parent
a3ab8746bf
commit
3791d82540
14 changed files with 46 additions and 60 deletions
|
@ -1,5 +1,6 @@
|
||||||
package eu.kanade.domain.chapter.model
|
package eu.kanade.domain.chapter.model
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.data.database.models.ChapterImpl
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter as DbChapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter as DbChapter
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ data class Chapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove when all deps are migrated
|
// TODO: Remove when all deps are migrated
|
||||||
fun Chapter.toDbChapter(): DbChapter = DbChapter.create().also {
|
fun Chapter.toDbChapter(): DbChapter = ChapterImpl().also {
|
||||||
it.id = id
|
it.id = id
|
||||||
it.manga_id = mangaId
|
it.manga_id = mangaId
|
||||||
it.url = url
|
it.url = url
|
||||||
|
|
|
@ -20,11 +20,7 @@ interface Chapter : SChapter, Serializable {
|
||||||
|
|
||||||
var source_order: Int
|
var source_order: Int
|
||||||
|
|
||||||
val isRecognizedNumber: Boolean
|
|
||||||
get() = chapter_number >= 0f
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun create(): Chapter = ChapterImpl().apply {
|
fun create(): Chapter = ChapterImpl().apply {
|
||||||
chapter_number = -1f
|
chapter_number = -1f
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,8 @@ import com.bluelinelabs.conductor.Controller
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import eu.kanade.domain.manga.interactor.GetManga
|
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.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.toDomainManga
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
|
@ -32,7 +30,6 @@ class SearchController(
|
||||||
runBlocking {
|
runBlocking {
|
||||||
Injekt.get<GetManga>()
|
Injekt.get<GetManga>()
|
||||||
.await(mangaId)
|
.await(mangaId)
|
||||||
?.toDbManga()
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -89,7 +86,7 @@ class SearchController(
|
||||||
if (!isReplacingManga) {
|
if (!isReplacingManga) {
|
||||||
router.popController(this)
|
router.popController(this)
|
||||||
if (newManga?.id != null) {
|
if (newManga?.id != null) {
|
||||||
val newMangaController = RouterTransaction.with(MangaController(newManga.id!!))
|
val newMangaController = RouterTransaction.with(MangaController(newManga.id))
|
||||||
if (router.backstack.lastOrNull()?.controller is MangaController) {
|
if (router.backstack.lastOrNull()?.controller is MangaController) {
|
||||||
// Replace old MangaController
|
// Replace old MangaController
|
||||||
router.replaceTopController(newMangaController)
|
router.replaceTopController(newMangaController)
|
||||||
|
@ -109,7 +106,7 @@ class SearchController(
|
||||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||||
val prefValue = preferences.migrateFlags().get()
|
val prefValue = preferences.migrateFlags().get()
|
||||||
val enabledFlagsPositions = MigrationFlags.getEnabledFlagsPositions(prefValue)
|
val enabledFlagsPositions = MigrationFlags.getEnabledFlagsPositions(prefValue)
|
||||||
val items = MigrationFlags.titles(manga?.toDomainManga())
|
val items = MigrationFlags.titles(manga)
|
||||||
.map { resources?.getString(it) }
|
.map { resources?.getString(it) }
|
||||||
.toTypedArray()
|
.toTypedArray()
|
||||||
val selected = items
|
val selected = items
|
||||||
|
@ -145,7 +142,7 @@ class SearchController(
|
||||||
}
|
}
|
||||||
.setNeutralButton(activity?.getString(R.string.action_show_manga)) { _, _ ->
|
.setNeutralButton(activity?.getString(R.string.action_show_manga)) { _, _ ->
|
||||||
dismissDialog()
|
dismissDialog()
|
||||||
router.pushController(MangaController(newManga!!.id!!))
|
router.pushController(MangaController(newManga!!.id))
|
||||||
}
|
}
|
||||||
.create()
|
.create()
|
||||||
}
|
}
|
||||||
|
@ -154,6 +151,6 @@ class SearchController(
|
||||||
override fun onTitleClick(source: CatalogueSource) {
|
override fun onTitleClick(source: CatalogueSource) {
|
||||||
presenter.preferences.lastUsedSource().set(source.id)
|
presenter.preferences.lastUsedSource().set(source.id)
|
||||||
|
|
||||||
router.pushController(SourceSearchController(manga?.toDomainManga(), source, presenter.query))
|
router.pushController(SourceSearchController(manga, source, presenter.query))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,15 +9,14 @@ import eu.kanade.domain.chapter.interactor.SyncChaptersWithSource
|
||||||
import eu.kanade.domain.chapter.interactor.UpdateChapter
|
import eu.kanade.domain.chapter.interactor.UpdateChapter
|
||||||
import eu.kanade.domain.chapter.model.toChapterUpdate
|
import eu.kanade.domain.chapter.model.toChapterUpdate
|
||||||
import eu.kanade.domain.manga.interactor.UpdateManga
|
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.MangaUpdate
|
||||||
import eu.kanade.domain.manga.model.hasCustomCover
|
import eu.kanade.domain.manga.model.hasCustomCover
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
import eu.kanade.domain.manga.model.toDbManga
|
||||||
|
import eu.kanade.domain.manga.model.toMangaInfo
|
||||||
import eu.kanade.domain.track.interactor.GetTracks
|
import eu.kanade.domain.track.interactor.GetTracks
|
||||||
import eu.kanade.domain.track.interactor.InsertTrack
|
import eu.kanade.domain.track.interactor.InsertTrack
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.toDomainManga
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.toMangaInfo
|
|
||||||
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
|
@ -76,7 +75,7 @@ class SearchPresenter(
|
||||||
return GlobalSearchItem(source, results, source.id == manga.source)
|
return GlobalSearchItem(source, results, source.id == manga.source)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun networkToLocalManga(sManga: SManga, sourceId: Long): Manga {
|
override fun networkToLocalManga(sManga: SManga, sourceId: Long): eu.kanade.tachiyomi.data.database.models.Manga {
|
||||||
val localManga = super.networkToLocalManga(sManga, sourceId)
|
val localManga = super.networkToLocalManga(sManga, sourceId)
|
||||||
// For migration, displayed title should always match source rather than local DB
|
// For migration, displayed title should always match source rather than local DB
|
||||||
localManga.title = sManga.title
|
localManga.title = sManga.title
|
||||||
|
@ -118,19 +117,16 @@ class SearchPresenter(
|
||||||
val migrateTracks = MigrationFlags.hasTracks(flags)
|
val migrateTracks = MigrationFlags.hasTracks(flags)
|
||||||
val migrateCustomCover = MigrationFlags.hasCustomCover(flags)
|
val migrateCustomCover = MigrationFlags.hasCustomCover(flags)
|
||||||
|
|
||||||
val prevDomainManga = prevManga.toDomainManga() ?: return
|
|
||||||
val domainManga = manga.toDomainManga() ?: return
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
syncChaptersWithSource.await(sourceChapters, domainManga, source)
|
syncChaptersWithSource.await(sourceChapters, manga, source)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// Worst case, chapters won't be synced
|
// Worst case, chapters won't be synced
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update chapters read, bookmark and dateFetch
|
// Update chapters read, bookmark and dateFetch
|
||||||
if (migrateChapters) {
|
if (migrateChapters) {
|
||||||
val prevMangaChapters = getChapterByMangaId.await(prevDomainManga.id)
|
val prevMangaChapters = getChapterByMangaId.await(prevManga.id)
|
||||||
val mangaChapters = getChapterByMangaId.await(domainManga.id)
|
val mangaChapters = getChapterByMangaId.await(manga.id)
|
||||||
|
|
||||||
val maxChapterRead = prevMangaChapters
|
val maxChapterRead = prevMangaChapters
|
||||||
.filter { it.read }
|
.filter { it.read }
|
||||||
|
@ -163,41 +159,41 @@ class SearchPresenter(
|
||||||
|
|
||||||
// Update categories
|
// Update categories
|
||||||
if (migrateCategories) {
|
if (migrateCategories) {
|
||||||
val categoryIds = getCategories.await(prevDomainManga.id).map { it.id }
|
val categoryIds = getCategories.await(prevManga.id).map { it.id }
|
||||||
setMangaCategories.await(domainManga.id, categoryIds)
|
setMangaCategories.await(manga.id, categoryIds)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update track
|
// Update track
|
||||||
if (migrateTracks) {
|
if (migrateTracks) {
|
||||||
val tracks = getTracks.await(prevDomainManga.id).mapNotNull { track ->
|
val tracks = getTracks.await(prevManga.id).mapNotNull { track ->
|
||||||
val updatedTrack = track.copy(mangaId = domainManga.id)
|
val updatedTrack = track.copy(mangaId = manga.id)
|
||||||
|
|
||||||
val service = enhancedServices
|
val service = enhancedServices
|
||||||
.firstOrNull { it.isTrackFrom(updatedTrack, prevDomainManga, prevSource) }
|
.firstOrNull { it.isTrackFrom(updatedTrack, prevManga, prevSource) }
|
||||||
|
|
||||||
if (service != null) service.migrateTrack(updatedTrack, domainManga, source)
|
if (service != null) service.migrateTrack(updatedTrack, manga, source)
|
||||||
else updatedTrack
|
else updatedTrack
|
||||||
}
|
}
|
||||||
insertTrack.awaitAll(tracks)
|
insertTrack.awaitAll(tracks)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replace) {
|
if (replace) {
|
||||||
updateManga.await(MangaUpdate(prevDomainManga.id, favorite = false, dateAdded = 0))
|
updateManga.await(MangaUpdate(prevManga.id, favorite = false, dateAdded = 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update custom cover (recheck if custom cover exists)
|
// Update custom cover (recheck if custom cover exists)
|
||||||
if (migrateCustomCover && prevDomainManga.hasCustomCover()) {
|
if (migrateCustomCover && prevManga.hasCustomCover()) {
|
||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
coverCache.setCustomCoverToCache(domainManga.toDbManga(), coverCache.getCustomCoverFile(prevDomainManga.id).inputStream())
|
coverCache.setCustomCoverToCache(manga.toDbManga(), coverCache.getCustomCoverFile(prevManga.id).inputStream())
|
||||||
}
|
}
|
||||||
|
|
||||||
updateManga.await(
|
updateManga.await(
|
||||||
MangaUpdate(
|
MangaUpdate(
|
||||||
id = domainManga.id,
|
id = manga.id,
|
||||||
favorite = true,
|
favorite = true,
|
||||||
chapterFlags = prevDomainManga.chapterFlags,
|
chapterFlags = prevManga.chapterFlags,
|
||||||
viewerFlags = prevDomainManga.viewerFlags,
|
viewerFlags = prevManga.viewerFlags,
|
||||||
dateAdded = if (replace) prevDomainManga.dateAdded else Date().time,
|
dateAdded = if (replace) prevManga.dateAdded else Date().time,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.browse.migration.search
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.kanade.domain.manga.model.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.SourceItem
|
import eu.kanade.tachiyomi.ui.browse.source.browse.SourceItem
|
||||||
|
@ -29,7 +28,7 @@ class SourceSearchController(
|
||||||
newManga = item.manga
|
newManga = item.manga
|
||||||
val searchController = router.backstack.findLast { it.controller.javaClass == SearchController::class.java }?.controller as SearchController?
|
val searchController = router.backstack.findLast { it.controller.javaClass == SearchController::class.java }?.controller as SearchController?
|
||||||
val dialog =
|
val dialog =
|
||||||
SearchController.MigrationDialog(oldManga?.toDbManga(), newManga?.toDbManga(), this)
|
SearchController.MigrationDialog(oldManga, newManga, this)
|
||||||
dialog.targetController = searchController
|
dialog.targetController = searchController
|
||||||
dialog.showDialog(router)
|
dialog.showDialog(router)
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
|
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
|
||||||
|
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter that holds the manga items from search results.
|
* Adapter that holds the manga items from search results.
|
||||||
|
|
|
@ -4,8 +4,8 @@ import android.view.View
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import coil.dispose
|
import coil.dispose
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
import eu.davidea.viewholders.FlexibleViewHolder
|
||||||
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.data.coil.MangaCoverFetcher
|
import eu.kanade.tachiyomi.data.coil.MangaCoverFetcher
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.databinding.GlobalSearchControllerCardItemBinding
|
import eu.kanade.tachiyomi.databinding.GlobalSearchControllerCardItemBinding
|
||||||
import eu.kanade.tachiyomi.util.view.loadAutoPause
|
import eu.kanade.tachiyomi.util.view.loadAutoPause
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
|
|
||||||
class GlobalSearchCardItem(val manga: Manga) : AbstractFlexibleItem<GlobalSearchCardHolder>() {
|
class GlobalSearchCardItem(val manga: Manga) : AbstractFlexibleItem<GlobalSearchCardHolder>() {
|
||||||
|
|
||||||
|
@ -35,6 +35,6 @@ class GlobalSearchCardItem(val manga: Manga) : AbstractFlexibleItem<GlobalSearch
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
return manga.id?.toInt() ?: 0
|
return manga.id.hashCode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import dev.chrisbanes.insetter.applyInsetter
|
import dev.chrisbanes.insetter.applyInsetter
|
||||||
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.databinding.GlobalSearchControllerBinding
|
import eu.kanade.tachiyomi.databinding.GlobalSearchControllerBinding
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
|
@ -65,7 +65,7 @@ open class GlobalSearchController(
|
||||||
* @param manga clicked item containing manga information.
|
* @param manga clicked item containing manga information.
|
||||||
*/
|
*/
|
||||||
override fun onMangaClick(manga: Manga) {
|
override fun onMangaClick(manga: Manga) {
|
||||||
router.pushController(MangaController(manga.id!!, true))
|
router.pushController(MangaController(manga.id, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@ import android.view.View
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
import eu.davidea.viewholders.FlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.databinding.GlobalSearchControllerCardBinding
|
import eu.kanade.tachiyomi.databinding.GlobalSearchControllerCardBinding
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
|
@ -92,7 +92,7 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
|
||||||
private fun getHolder(manga: Manga): GlobalSearchCardHolder? {
|
private fun getHolder(manga: Manga): GlobalSearchCardHolder? {
|
||||||
mangaAdapter.allBoundViewHolders.forEach { holder ->
|
mangaAdapter.allBoundViewHolders.forEach { holder ->
|
||||||
val item = mangaAdapter.getItem(holder.bindingAdapterPosition)
|
val item = mangaAdapter.getItem(holder.bindingAdapterPosition)
|
||||||
if (item != null && item.manga.id!! == manga.id!!) {
|
if (item != null && item.manga.id == manga.id) {
|
||||||
return holder as GlobalSearchCardHolder
|
return holder as GlobalSearchCardHolder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ open class GlobalSearchPresenter(
|
||||||
.map { it.mangas }
|
.map { it.mangas }
|
||||||
.map { list -> list.map { networkToLocalManga(it, source.id) } } // Convert to local manga
|
.map { list -> list.map { networkToLocalManga(it, source.id) } } // Convert to local manga
|
||||||
.doOnNext { fetchImage(it, source) } // Load manga covers
|
.doOnNext { fetchImage(it, source) } // Load manga covers
|
||||||
.map { list -> createCatalogueSearchItem(source, list.map { GlobalSearchCardItem(it) }) }
|
.map { list -> createCatalogueSearchItem(source, list.map { GlobalSearchCardItem(it.toDomainManga()!!) }) }
|
||||||
},
|
},
|
||||||
5,
|
5,
|
||||||
)
|
)
|
||||||
|
@ -238,7 +238,7 @@ open class GlobalSearchPresenter(
|
||||||
.subscribe(
|
.subscribe(
|
||||||
{ (source, manga) ->
|
{ (source, manga) ->
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
view?.onMangaInitialized(source, manga)
|
view?.onMangaInitialized(source, manga.toDomainManga()!!)
|
||||||
},
|
},
|
||||||
{ error ->
|
{ error ->
|
||||||
logcat(LogPriority.ERROR, error)
|
logcat(LogPriority.ERROR, error)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import eu.kanade.domain.category.interactor.SetMangaCategories
|
||||||
import eu.kanade.domain.category.model.Category
|
import eu.kanade.domain.category.model.Category
|
||||||
import eu.kanade.domain.chapter.interactor.GetChapterByMangaId
|
import eu.kanade.domain.chapter.interactor.GetChapterByMangaId
|
||||||
import eu.kanade.domain.chapter.interactor.UpdateChapter
|
import eu.kanade.domain.chapter.interactor.UpdateChapter
|
||||||
|
import eu.kanade.domain.chapter.model.Chapter
|
||||||
import eu.kanade.domain.chapter.model.ChapterUpdate
|
import eu.kanade.domain.chapter.model.ChapterUpdate
|
||||||
import eu.kanade.domain.chapter.model.toDbChapter
|
import eu.kanade.domain.chapter.model.toDbChapter
|
||||||
import eu.kanade.domain.manga.interactor.GetLibraryManga
|
import eu.kanade.domain.manga.interactor.GetLibraryManga
|
||||||
|
@ -19,7 +20,6 @@ import eu.kanade.domain.manga.model.isLocal
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
import eu.kanade.domain.manga.model.toDbManga
|
||||||
import eu.kanade.domain.track.interactor.GetTracks
|
import eu.kanade.domain.track.interactor.GetTracks
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.toDomainManga
|
import eu.kanade.tachiyomi.data.database.models.toDomainManga
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
@ -547,7 +547,7 @@ class LibraryPresenter(
|
||||||
updateChapter.awaitAll(toUpdate)
|
updateChapter.awaitAll(toUpdate)
|
||||||
|
|
||||||
if (read && preferences.removeAfterMarkedAsRead()) {
|
if (read && preferences.removeAfterMarkedAsRead()) {
|
||||||
deleteChapters(manga, chapters.map { it.toDbChapter() })
|
deleteChapters(manga, chapters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -555,7 +555,7 @@ class LibraryPresenter(
|
||||||
|
|
||||||
private fun deleteChapters(manga: Manga, chapters: List<Chapter>) {
|
private fun deleteChapters(manga: Manga, chapters: List<Chapter>) {
|
||||||
sourceManager.get(manga.source)?.let { source ->
|
sourceManager.get(manga.source)?.let { source ->
|
||||||
downloadManager.deleteChapters(chapters, manga.toDbManga(), source)
|
downloadManager.deleteChapters(chapters.map { it.toDbChapter() }, manga.toDbManga(), source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -352,7 +352,7 @@ class MangaController :
|
||||||
*/
|
*/
|
||||||
private fun migrateManga() {
|
private fun migrateManga() {
|
||||||
val manga = presenter.manga ?: return
|
val manga = presenter.manga ?: return
|
||||||
val controller = SearchController(manga.toDbManga())
|
val controller = SearchController(manga)
|
||||||
controller.targetController = this
|
controller.targetController = this
|
||||||
router.pushController(controller)
|
router.pushController(controller)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,7 @@ import eu.kanade.domain.track.interactor.GetTracks
|
||||||
import eu.kanade.domain.track.interactor.InsertTrack
|
import eu.kanade.domain.track.interactor.InsertTrack
|
||||||
import eu.kanade.domain.track.model.toDbTrack
|
import eu.kanade.domain.track.model.toDbTrack
|
||||||
import eu.kanade.domain.track.model.toDomainTrack
|
import eu.kanade.domain.track.model.toDomainTrack
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.Track
|
import eu.kanade.tachiyomi.data.database.models.Track
|
||||||
import eu.kanade.tachiyomi.data.database.models.toDomainChapter
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
@ -375,7 +373,7 @@ class MangaPresenter(
|
||||||
getTracks.subscribe(manga.id)
|
getTracks.subscribe(manga.id)
|
||||||
.catch { logcat(LogPriority.ERROR, it) }
|
.catch { logcat(LogPriority.ERROR, it) }
|
||||||
.map { tracks ->
|
.map { tracks ->
|
||||||
val loggedServicesId = loggedServices.map { it.id.toLong() }
|
val loggedServicesId = loggedServices.map { it.id }
|
||||||
tracks.filter { it.syncId in loggedServicesId }.size
|
tracks.filter { it.syncId in loggedServicesId }.size
|
||||||
}
|
}
|
||||||
.collectLatest { trackingCount ->
|
.collectLatest { trackingCount ->
|
||||||
|
@ -464,8 +462,7 @@ class MangaPresenter(
|
||||||
)
|
)
|
||||||
|
|
||||||
if (manualFetch) {
|
if (manualFetch) {
|
||||||
val dbChapters = newChapters.map { it.toDbChapter() }
|
downloadNewChapters(newChapters)
|
||||||
downloadNewChapters(dbChapters)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
|
@ -592,12 +589,12 @@ class MangaPresenter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun downloadNewChapters(chapters: List<Chapter>) {
|
private fun downloadNewChapters(chapters: List<DomainChapter>) {
|
||||||
presenterScope.launchIO {
|
presenterScope.launchIO {
|
||||||
val manga = successState?.manga ?: return@launchIO
|
val manga = successState?.manga ?: return@launchIO
|
||||||
val categories = getCategories.await(manga.id).map { it.id }
|
val categories = getCategories.await(manga.id).map { it.id }
|
||||||
if (chapters.isEmpty() || !manga.shouldDownloadNewChapters(categories, preferences)) return@launchIO
|
if (chapters.isEmpty() || !manga.shouldDownloadNewChapters(categories, preferences)) return@launchIO
|
||||||
downloadChapters(chapters.map { it.toDomainChapter()!! })
|
downloadChapters(chapters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -784,7 +781,7 @@ class MangaPresenter(
|
||||||
val manga = successState?.manga ?: return
|
val manga = successState?.manga ?: return
|
||||||
|
|
||||||
presenterScope.launchIO {
|
presenterScope.launchIO {
|
||||||
deleteTrack.await(manga.id, service.id.toLong())
|
deleteTrack.await(manga.id, service.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue