Remove EH legacy code
This commit is contained in:
parent
99b1f6e56f
commit
fa7c6716f4
@ -66,61 +66,41 @@ class EHentaiUpdateHelper(context: Context) {
|
|||||||
// Copy chain chapters to curChapters
|
// Copy chain chapters to curChapters
|
||||||
val newChapters = toDiscard
|
val newChapters = toDiscard
|
||||||
.flatMap { chain ->
|
.flatMap { chain ->
|
||||||
val meta by lazy {
|
chain.chapters
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.fold(accepted.chapters) { curChapters, chapter ->
|
.fold(accepted.chapters) { curChapters, chapter ->
|
||||||
val existing = curChapters.find { it.url == chapter.url }
|
val existing = curChapters.find { it.url == chapter.url }
|
||||||
|
|
||||||
val newLastPageRead = chainsAsChapters.maxByOrNull { it.last_page_read }?.last_page_read
|
val newLastPageRead = chainsAsChapters.maxByOrNull { it.last_page_read }?.last_page_read
|
||||||
|
|
||||||
when {
|
if (existing != null) {
|
||||||
existing != null -> {
|
existing.read = existing.read || chapter.read
|
||||||
existing.read = existing.read || chapter.read
|
existing.last_page_read = existing.last_page_read.coerceAtLeast(chapter.last_page_read)
|
||||||
existing.last_page_read = existing.last_page_read.coerceAtLeast(chapter.last_page_read)
|
if (newLastPageRead != null && existing.last_page_read <= 0) {
|
||||||
if (newLastPageRead != null && existing.last_page_read <= 0) {
|
existing.last_page_read = newLastPageRead
|
||||||
existing.last_page_read = newLastPageRead
|
|
||||||
}
|
|
||||||
existing.bookmark = existing.bookmark || chapter.bookmark
|
|
||||||
curChapters
|
|
||||||
}
|
}
|
||||||
chapter.date_upload > 0 -> { // Ignore chapters using the old system
|
existing.bookmark = existing.bookmark || chapter.bookmark
|
||||||
new = true
|
curChapters
|
||||||
curChapters + ChapterImpl().apply {
|
}
|
||||||
manga_id = accepted.manga.id
|
else {
|
||||||
url = chapter.url
|
new = true
|
||||||
name = chapter.name
|
curChapters + ChapterImpl().apply {
|
||||||
read = chapter.read
|
manga_id = accepted.manga.id
|
||||||
bookmark = chapter.bookmark
|
url = chapter.url
|
||||||
|
name = chapter.name
|
||||||
|
read = chapter.read
|
||||||
|
bookmark = chapter.bookmark
|
||||||
|
|
||||||
last_page_read = chapter.last_page_read
|
last_page_read = chapter.last_page_read
|
||||||
if (newLastPageRead != null && last_page_read <= 0) {
|
if (newLastPageRead != null && last_page_read <= 0) {
|
||||||
last_page_read = newLastPageRead
|
last_page_read = newLastPageRead
|
||||||
}
|
|
||||||
|
|
||||||
date_fetch = chapter.date_fetch
|
|
||||||
date_upload = chapter.date_upload
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
date_fetch = chapter.date_fetch
|
||||||
|
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 }
|
.sortedBy { it.date_upload }
|
||||||
.apply {
|
.apply {
|
||||||
mapIndexed { index, chapter ->
|
mapIndexed { index, chapter ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user