Remove EH legacy code

This commit is contained in:
Jobobby04 2020-10-24 19:07:46 -04:00
parent 99b1f6e56f
commit fa7c6716f4

View File

@ -66,31 +66,14 @@ class EHentaiUpdateHelper(context: Context) {
// Copy chain chapters to curChapters
val newChapters = toDiscard
.flatMap { chain ->
val meta by lazy {
db.getFlatMetadataForManga(chain.manga.id!!)
.executeAsBlocking()
?.raise<EHentaiSearchMetadata>()
}
chain.chapters.map { chapter ->
// Convert old style chapters to new style chapters if possible
if (chapter.date_upload <= 0 &&
meta?.datePosted != null &&
meta?.title != null
) {
chapter.name = meta!!.title!!
chapter.date_upload = meta!!.datePosted!!
}
chapter
}
chain.chapters
}
.fold(accepted.chapters) { curChapters, chapter ->
val existing = curChapters.find { it.url == chapter.url }
val newLastPageRead = chainsAsChapters.maxByOrNull { it.last_page_read }?.last_page_read
when {
existing != null -> {
if (existing != null) {
existing.read = existing.read || chapter.read
existing.last_page_read = existing.last_page_read.coerceAtLeast(chapter.last_page_read)
if (newLastPageRead != null && existing.last_page_read <= 0) {
@ -99,7 +82,7 @@ class EHentaiUpdateHelper(context: Context) {
existing.bookmark = existing.bookmark || chapter.bookmark
curChapters
}
chapter.date_upload > 0 -> { // Ignore chapters using the old system
else {
new = true
curChapters + ChapterImpl().apply {
manga_id = accepted.manga.id
@ -117,10 +100,7 @@ class EHentaiUpdateHelper(context: Context) {
date_upload = chapter.date_upload
}
}
else -> curChapters
}
}
.filter { it.date_upload > 0 } // Ignore chapters using the old system (filter after to prevent dupes from insert)
.sortedBy { it.date_upload }
.apply {
mapIndexed { index, chapter ->