From a9d2741e6ab1f2c54398703a3ae7c0272a458b89 Mon Sep 17 00:00:00 2001 From: jmir1 <43830312+jmir1@users.noreply.github.com> Date: Sat, 4 Dec 2021 15:59:39 +0100 Subject: [PATCH] Automatically set tracker as completed after reading the last chapter (#6289) * Automatically set tracker as completed after reading the last chapter. * use integer value in comparison * also set `started_reading` date * don't use source manga's status * remove useless line --- .../kanade/tachiyomi/data/track/anilist/Anilist.kt | 12 ++++++++++-- .../kanade/tachiyomi/data/track/bangumi/Bangumi.kt | 6 +++++- .../eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt | 10 +++++++++- .../eu/kanade/tachiyomi/data/track/komga/Komga.kt | 6 +++++- .../tachiyomi/data/track/myanimelist/MyAnimeList.kt | 12 ++++++++++-- .../tachiyomi/data/track/shikimori/Shikimori.kt | 8 ++++++-- 6 files changed, 45 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt index c2f574600..ecaa0093e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt @@ -147,8 +147,16 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) { } if (track.status != COMPLETED) { - if (track.status != REPEATING && didReadChapter) { - track.status = READING + if (didReadChapter) { + if (track.last_chapter_read.toInt() == track.total_chapters && track.total_chapters > 0) { + track.status = COMPLETED + track.finished_reading_date = System.currentTimeMillis() + } else if (track.status != REPEATING) { + track.status = READING + if (track.last_chapter_read == 1F) { + track.started_reading_date = System.currentTimeMillis() + } + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt index 475f1d53c..7cdec90d3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt @@ -38,7 +38,11 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) { override suspend fun update(track: Track, didReadChapter: Boolean): Track { if (track.status != COMPLETED) { if (didReadChapter) { - track.status = READING + if (track.last_chapter_read.toInt() == track.total_chapters && track.total_chapters > 0) { + track.status = COMPLETED + } else { + track.status = READING + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt index 233681830..75a456786 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt @@ -80,7 +80,15 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) { override suspend fun update(track: Track, didReadChapter: Boolean): Track { if (track.status != COMPLETED) { if (didReadChapter) { - track.status = READING + if (track.last_chapter_read.toInt() == track.total_chapters && track.total_chapters > 0) { + track.status = COMPLETED + track.finished_reading_date = System.currentTimeMillis() + } else { + track.status = READING + if (track.last_chapter_read == 1F) { + track.started_reading_date = System.currentTimeMillis() + } + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt index 9628a68f0..e55055c6d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt @@ -59,7 +59,11 @@ class Komga(private val context: Context, id: Int) : TrackService(id), EnhancedT override suspend fun update(track: Track, didReadChapter: Boolean): Track { if (track.status != COMPLETED) { if (didReadChapter) { - track.status = READING + if (track.last_chapter_read.toInt() == track.total_chapters && track.total_chapters > 0) { + track.status = COMPLETED + } else { + track.status = READING + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt index e5a82885d..ffed4c15d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt @@ -76,8 +76,16 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) { override suspend fun update(track: Track, didReadChapter: Boolean): Track { if (track.status != COMPLETED) { - if (track.status != REREADING && didReadChapter) { - track.status = READING + if (didReadChapter) { + if (track.last_chapter_read.toInt() == track.total_chapters && track.total_chapters > 0) { + track.status = COMPLETED + track.finished_reading_date = System.currentTimeMillis() + } else if (track.status != REREADING) { + track.status = READING + if (track.last_chapter_read == 1F) { + track.started_reading_date = System.currentTimeMillis() + } + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt index 308bd3ded..e21ce491e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt @@ -46,8 +46,12 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) { override suspend fun update(track: Track, didReadChapter: Boolean): Track { if (track.status != COMPLETED) { - if (track.status != REPEATING && didReadChapter) { - track.status = READING + if (didReadChapter) { + if (track.last_chapter_read.toInt() == track.total_chapters && track.total_chapters > 0) { + track.status = COMPLETED + } else if (track.status != REPEATING) { + track.status = READING + } } }