More domain model usage in SY
This commit is contained in:
parent
9a10f1300a
commit
f4a3ef4f1d
@ -22,7 +22,6 @@ import eu.kanade.domain.manga.model.Manga
|
|||||||
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.manga.model.toMangaInfo
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
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.databinding.MigrationListControllerBinding
|
import eu.kanade.tachiyomi.databinding.MigrationListControllerBinding
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
@ -183,7 +182,7 @@ class MigrationListController(bundle: Bundle? = null) :
|
|||||||
val localManga = smartSearchEngine.networkToLocalManga(
|
val localManga = smartSearchEngine.networkToLocalManga(
|
||||||
searchResult,
|
searchResult,
|
||||||
source.id,
|
source.id,
|
||||||
).toDomainManga()!!
|
)
|
||||||
|
|
||||||
val chapters = if (source is EHentai) {
|
val chapters = if (source is EHentai) {
|
||||||
source.getChapterList(localManga.toMangaInfo(), throttleManager::throttle)
|
source.getChapterList(localManga.toMangaInfo(), throttleManager::throttle)
|
||||||
@ -220,7 +219,7 @@ class MigrationListController(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (searchResult != null) {
|
if (searchResult != null) {
|
||||||
val localManga = smartSearchEngine.networkToLocalManga(searchResult, source.id).toDomainManga()!!
|
val localManga = smartSearchEngine.networkToLocalManga(searchResult, source.id)
|
||||||
val chapters = try {
|
val chapters = try {
|
||||||
if (source is EHentai) {
|
if (source is EHentai) {
|
||||||
source.getChapterList(localManga.toMangaInfo(), throttleManager::throttle)
|
source.getChapterList(localManga.toMangaInfo(), throttleManager::throttle)
|
||||||
@ -357,7 +356,7 @@ class MigrationListController(bundle: Bundle? = null) :
|
|||||||
adapter?.notifyItemChanged(firstIndex)
|
adapter?.notifyItemChanged(firstIndex)
|
||||||
launchUI {
|
launchUI {
|
||||||
val result = CoroutineScope(migratingManga.manga.migrationJob).async {
|
val result = CoroutineScope(migratingManga.manga.migrationJob).async {
|
||||||
val localManga = smartSearchEngine.networkToLocalManga(manga.toDbManga(), source.id).toDomainManga()!!
|
val localManga = smartSearchEngine.networkToLocalManga(manga.toDbManga(), source.id)
|
||||||
try {
|
try {
|
||||||
val chapters = source.getChapterList(localManga.toMangaInfo())
|
val chapters = source.getChapterList(localManga.toMangaInfo())
|
||||||
.map { it.toSChapter() }
|
.map { it.toSChapter() }
|
||||||
|
@ -2,8 +2,7 @@ package exh.smartsearch
|
|||||||
|
|
||||||
import eu.kanade.domain.manga.interactor.GetManga
|
import eu.kanade.domain.manga.interactor.GetManga
|
||||||
import eu.kanade.domain.manga.interactor.InsertManga
|
import eu.kanade.domain.manga.interactor.InsertManga
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.toDomainManga
|
import eu.kanade.tachiyomi.data.database.models.toDomainManga
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
@ -15,6 +14,7 @@ import kotlinx.coroutines.async
|
|||||||
import kotlinx.coroutines.supervisorScope
|
import kotlinx.coroutines.supervisorScope
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import eu.kanade.tachiyomi.data.database.models.Manga.Companion as DbManga
|
||||||
|
|
||||||
class SmartSearchEngine(
|
class SmartSearchEngine(
|
||||||
private val extraSearchParams: String? = null,
|
private val extraSearchParams: String? = null,
|
||||||
@ -175,7 +175,7 @@ class SmartSearchEngine(
|
|||||||
suspend fun networkToLocalManga(sManga: SManga, sourceId: Long): Manga {
|
suspend fun networkToLocalManga(sManga: SManga, sourceId: Long): Manga {
|
||||||
var localManga = getManga.await(sManga.url, sourceId)
|
var localManga = getManga.await(sManga.url, sourceId)
|
||||||
if (localManga == null) {
|
if (localManga == null) {
|
||||||
val newManga = Manga.create(sManga.url, sManga.title, sourceId)
|
val newManga = DbManga.create(sManga.url, sManga.title, sourceId)
|
||||||
newManga.copyFrom(sManga)
|
newManga.copyFrom(sManga)
|
||||||
newManga.id = -1
|
newManga.id = -1
|
||||||
val result = run {
|
val result = run {
|
||||||
@ -188,7 +188,7 @@ class SmartSearchEngine(
|
|||||||
// if it later becomes a favorite, updated title will go to db
|
// if it later becomes a favorite, updated title will go to db
|
||||||
localManga = localManga.copy(ogTitle = sManga.title)
|
localManga = localManga.copy(ogTitle = sManga.title)
|
||||||
}
|
}
|
||||||
return localManga?.toDbManga()!!
|
return localManga!!
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -43,7 +43,7 @@ class SmartSearchController(bundle: Bundle) : NucleusController<EhSmartSearchBin
|
|||||||
presenter.smartSearchFlow
|
presenter.smartSearchFlow
|
||||||
.onEach { results ->
|
.onEach { results ->
|
||||||
if (results is SmartSearchPresenter.SearchResults.Found) {
|
if (results is SmartSearchPresenter.SearchResults.Found) {
|
||||||
val transaction = MangaController(results.manga.id!!, true, smartSearchConfig).withFadeTransaction()
|
val transaction = MangaController(results.manga.id, true, smartSearchConfig).withFadeTransaction()
|
||||||
router.replaceTopController(transaction)
|
router.replaceTopController(transaction)
|
||||||
} else {
|
} else {
|
||||||
if (results is SmartSearchPresenter.SearchResults.NotFound) {
|
if (results is SmartSearchPresenter.SearchResults.NotFound) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package exh.ui.smartsearch
|
package exh.ui.smartsearch
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.domain.manga.model.Manga
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
|
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
|
||||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package exh.util
|
package exh.util
|
||||||
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import exh.metadata.metadata.base.RaisedTag
|
import exh.metadata.metadata.base.RaisedTag
|
||||||
import exh.source.EH_SOURCE_ID
|
import exh.source.EH_SOURCE_ID
|
||||||
import exh.source.EXH_SOURCE_ID
|
import exh.source.EXH_SOURCE_ID
|
||||||
@ -131,7 +130,3 @@ object SourceTagsUtil {
|
|||||||
|
|
||||||
private val spaceRegex = "\\s".toRegex()
|
private val spaceRegex = "\\s".toRegex()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Manga.getRaisedTags(genres: List<String>? = getGenres()): List<RaisedTag>? = genres?.map {
|
|
||||||
SourceTagsUtil.parseTag(it)
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user