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 != 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()
}
}
}
}

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 {
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
}
}
}

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 {
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()
}
}
}
}

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 {
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
}
}
}

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 {
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()
}
}
}
}

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 {
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
}
}
}