Probably make previously read exh chapters affect updated gallery chapters when loading the new version in the source
This commit is contained in:
parent
41b8786415
commit
444d346874
@ -94,6 +94,17 @@ interface ChapterQueries : DbProvider {
|
|||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.prepare()
|
.prepare()
|
||||||
|
|
||||||
|
fun getChaptersReadWithUrls(urls: List<String>) = db.get()
|
||||||
|
.listOfObjects(Chapter::class.java)
|
||||||
|
.withQuery(
|
||||||
|
Query.builder()
|
||||||
|
.table(ChapterTable.TABLE)
|
||||||
|
.where("${ChapterTable.COL_URL} IN (?) AND ${ChapterTable.COL_READ} = 1")
|
||||||
|
.whereArgs(urls.joinToString { "\"$it\"" })
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
.prepare()
|
||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
fun insertChapter(chapter: Chapter) = db.put().`object`(chapter).prepare()
|
fun insertChapter(chapter: Chapter) = db.put().`object`(chapter).prepare()
|
||||||
|
@ -9,6 +9,7 @@ import eu.kanade.tachiyomi.source.model.SChapter
|
|||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import exh.EH_SOURCE_ID
|
import exh.EH_SOURCE_ID
|
||||||
import exh.EXH_SOURCE_ID
|
import exh.EXH_SOURCE_ID
|
||||||
|
import exh.debug.DebugToggles
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.TreeSet
|
import java.util.TreeSet
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
@ -137,13 +138,24 @@ fun syncChaptersWithSource(
|
|||||||
if (manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID) {
|
if (manga.source == EH_SOURCE_ID || manga.source == EXH_SOURCE_ID) {
|
||||||
val finalAdded = toAdd.subtract(readded)
|
val finalAdded = toAdd.subtract(readded)
|
||||||
if (finalAdded.isNotEmpty()) {
|
if (finalAdded.isNotEmpty()) {
|
||||||
val max = dbChapters.maxBy { it.last_page_read }
|
val max = dbChapters.maxByOrNull { it.last_page_read }
|
||||||
if (max != null && max.last_page_read > 0) {
|
if (max != null && max.last_page_read > 0) {
|
||||||
for (chapter in finalAdded) {
|
for (chapter in finalAdded) {
|
||||||
chapter.last_page_read = max.last_page_read
|
chapter.last_page_read = max.last_page_read
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (readded.isEmpty() && !DebugToggles.INCLUDE_ONLY_ROOT_WHEN_LOADING_EXH_VERSIONS.enabled) {
|
||||||
|
val readChapters = db.getChaptersReadWithUrls(finalAdded.map { it.url }).executeAsBlocking()
|
||||||
|
if (readChapters.isNotEmpty()) {
|
||||||
|
finalAdded.onEach { chapter ->
|
||||||
|
readChapters.firstOrNull { it.url == chapter.url }?.let {
|
||||||
|
chapter.read = true
|
||||||
|
chapter.last_page_read = it.last_page_read
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// <-- EXH
|
// <-- EXH
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user