mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-26 07:06:03 +03:00
Chapter Metadata update (#1257)
* change chapter update to refresh on any metadata change * moved check into private function
This commit is contained in:
parent
0d480dbf7c
commit
9194dc0161
1 changed files with 17 additions and 7 deletions
|
@ -49,15 +49,18 @@ fun syncChaptersWithSource(db: DatabaseHelper,
|
||||||
// Add the chapter if not in db already, or update if the metadata changed.
|
// Add the chapter if not in db already, or update if the metadata changed.
|
||||||
if (dbChapter == null) {
|
if (dbChapter == null) {
|
||||||
toAdd.add(sourceChapter)
|
toAdd.add(sourceChapter)
|
||||||
} else if (dbChapter.scanlator != sourceChapter.scanlator ||
|
} else {
|
||||||
dbChapter.name != sourceChapter.name) {
|
//this forces metadata update for the main viewable things in the chapter list
|
||||||
|
ChapterRecognition.parseChapterNumber(sourceChapter, manga)
|
||||||
|
if (shouldUpdateDbChapter(dbChapter, sourceChapter)) {
|
||||||
dbChapter.scanlator = sourceChapter.scanlator
|
dbChapter.scanlator = sourceChapter.scanlator
|
||||||
dbChapter.name = sourceChapter.name
|
dbChapter.name = sourceChapter.name
|
||||||
|
dbChapter.date_upload = sourceChapter.date_upload
|
||||||
|
dbChapter.chapter_number = sourceChapter.chapter_number
|
||||||
toChange.add(dbChapter)
|
toChange.add(dbChapter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Recognize number for new chapters.
|
// Recognize number for new chapters.
|
||||||
toAdd.forEach {
|
toAdd.forEach {
|
||||||
|
@ -123,3 +126,10 @@ fun syncChaptersWithSource(db: DatabaseHelper,
|
||||||
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: SChapter): Boolean {
|
||||||
|
return dbChapter.scanlator != sourceChapter.scanlator || dbChapter.name != sourceChapter.name ||
|
||||||
|
dbChapter.date_upload != sourceChapter.date_upload ||
|
||||||
|
dbChapter.chapter_number != sourceChapter.chapter_number
|
||||||
|
}
|
Loading…
Reference in a new issue