From 9194dc0161254506787fe4020eda7e13f03f40da Mon Sep 17 00:00:00 2001 From: Carlos Date: Sun, 18 Feb 2018 13:20:05 -0500 Subject: [PATCH] Chapter Metadata update (#1257) * change chapter update to refresh on any metadata change * moved check into private function --- .../tachiyomi/util/ChapterSourceSync.kt | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterSourceSync.kt b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterSourceSync.kt index 36252f610..ccd9f14cc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterSourceSync.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterSourceSync.kt @@ -49,13 +49,16 @@ fun syncChaptersWithSource(db: DatabaseHelper, // Add the chapter if not in db already, or update if the metadata changed. if (dbChapter == null) { toAdd.add(sourceChapter) - } else if (dbChapter.scanlator != sourceChapter.scanlator || - dbChapter.name != sourceChapter.name) { - - dbChapter.scanlator = sourceChapter.scanlator - dbChapter.name = sourceChapter.name - - toChange.add(dbChapter) + } else { + //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.name = sourceChapter.name + dbChapter.date_upload = sourceChapter.date_upload + dbChapter.chapter_number = sourceChapter.chapter_number + toChange.add(dbChapter) + } } } @@ -123,3 +126,10 @@ fun syncChaptersWithSource(db: DatabaseHelper, 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 +} \ No newline at end of file