Fix chapter source order not working correctly and allow refresh to update source order
Based on https://github.com/CarlosEsco/Neko/commit/00f916a4f0e8d677f8e2107e92139d43d88606ae
Co-authored-by: CarlosEsco <CarlosEsco@users.noreply.github.com>
(cherry picked from commit 07e5525c74)
This commit is contained in:
@@ -75,6 +75,7 @@ fun syncChaptersWithSource(
|
|||||||
dbChapter.name = sourceChapter.name
|
dbChapter.name = sourceChapter.name
|
||||||
dbChapter.date_upload = sourceChapter.date_upload
|
dbChapter.date_upload = sourceChapter.date_upload
|
||||||
dbChapter.chapter_number = sourceChapter.chapter_number
|
dbChapter.chapter_number = sourceChapter.chapter_number
|
||||||
|
dbChapter.source_order = sourceChapter.source_order
|
||||||
toChange.add(dbChapter)
|
toChange.add(dbChapter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +175,9 @@ fun syncChaptersWithSource(
|
|||||||
db.insertChapters(toChange).executeAsBlocking()
|
db.insertChapters(toChange).executeAsBlocking()
|
||||||
}
|
}
|
||||||
|
|
||||||
val topChapters = db.getChapters(manga).executeAsBlocking().sortedByDescending { it.date_upload }.take(4)
|
val topChapters = db.getChapters(manga).executeAsBlocking()
|
||||||
|
.sortedByDescending { it.date_upload }
|
||||||
|
.take(4)
|
||||||
// Recalculate next update since chapters were changed
|
// Recalculate next update since chapters were changed
|
||||||
if (topChapters.size > 1) {
|
if (topChapters.size > 1) {
|
||||||
var delta = 0L
|
var delta = 0L
|
||||||
@@ -203,11 +206,11 @@ fun syncChaptersWithSource(
|
|||||||
return Pair(toAdd.subtract(readded).toList(), toDelete.subtract(readded).toList())
|
return Pair(toAdd.subtract(readded).toList(), toDelete.subtract(readded).toList())
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks if the chapter in db needs updated
|
private fun shouldUpdateDbChapter(dbChapter: Chapter, sourceChapter: Chapter): Boolean {
|
||||||
private fun shouldUpdateDbChapter(dbChapter: Chapter, sourceChapter: SChapter): Boolean {
|
|
||||||
return dbChapter.scanlator != sourceChapter.scanlator || dbChapter.name != sourceChapter.name ||
|
return dbChapter.scanlator != sourceChapter.scanlator || dbChapter.name != sourceChapter.name ||
|
||||||
dbChapter.date_upload != sourceChapter.date_upload ||
|
dbChapter.date_upload != sourceChapter.date_upload ||
|
||||||
dbChapter.chapter_number != sourceChapter.chapter_number
|
dbChapter.chapter_number != sourceChapter.chapter_number ||
|
||||||
|
dbChapter.source_order != sourceChapter.source_order
|
||||||
}
|
}
|
||||||
|
|
||||||
class NoChaptersException : Exception()
|
class NoChaptersException : Exception()
|
||||||
|
|||||||
Reference in New Issue
Block a user