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
This commit is contained in:
jmir1 2021-12-04 15:59:39 +01:00 committed by GitHub
parent 12bd7268d2
commit a9d2741e6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 9 deletions

View File

@ -147,8 +147,16 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
} }
if (track.status != COMPLETED) { if (track.status != COMPLETED) {
if (track.status != REPEATING && didReadChapter) { 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 if (track.status != REPEATING) {
track.status = READING
if (track.last_chapter_read == 1F) {
track.started_reading_date = System.currentTimeMillis()
}
}
} }
} }

View File

@ -38,7 +38,11 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
override suspend fun update(track: Track, didReadChapter: Boolean): Track { override suspend fun update(track: Track, didReadChapter: Boolean): Track {
if (track.status != COMPLETED) { if (track.status != COMPLETED) {
if (didReadChapter) { 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
}
} }
} }

View File

@ -80,7 +80,15 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
override suspend fun update(track: Track, didReadChapter: Boolean): Track { override suspend fun update(track: Track, didReadChapter: Boolean): Track {
if (track.status != COMPLETED) { if (track.status != COMPLETED) {
if (didReadChapter) { 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()
}
}
} }
} }

View File

@ -59,7 +59,11 @@ class Komga(private val context: Context, id: Int) : TrackService(id), EnhancedT
override suspend fun update(track: Track, didReadChapter: Boolean): Track { override suspend fun update(track: Track, didReadChapter: Boolean): Track {
if (track.status != COMPLETED) { if (track.status != COMPLETED) {
if (didReadChapter) { 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
}
} }
} }

View File

@ -76,8 +76,16 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
override suspend fun update(track: Track, didReadChapter: Boolean): Track { override suspend fun update(track: Track, didReadChapter: Boolean): Track {
if (track.status != COMPLETED) { if (track.status != COMPLETED) {
if (track.status != REREADING && didReadChapter) { 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 if (track.status != REREADING) {
track.status = READING
if (track.last_chapter_read == 1F) {
track.started_reading_date = System.currentTimeMillis()
}
}
} }
} }

View File

@ -46,8 +46,12 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
override suspend fun update(track: Track, didReadChapter: Boolean): Track { override suspend fun update(track: Track, didReadChapter: Boolean): Track {
if (track.status != COMPLETED) { if (track.status != COMPLETED) {
if (track.status != REPEATING && didReadChapter) { if (didReadChapter) {
track.status = READING if (track.last_chapter_read.toInt() == track.total_chapters && track.total_chapters > 0) {
track.status = COMPLETED
} else if (track.status != REPEATING) {
track.status = READING
}
} }
} }