Mark manga complete on mangadex when all chapters are marked in mdlist

(cherry picked from commit b95cca91fc19fedb42fce895e0a5f062e342dc21)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/data/track/mdlist/MdList.kt
This commit is contained in:
Carlos 2021-01-13 20:10:33 -05:00 committed by Jobobby04
parent 4a268de6dc
commit 5fefefcb23
2 changed files with 10 additions and 2 deletions

View File

@ -53,7 +53,7 @@ class MdList(private val context: Context, id: Int) : TrackService(id) {
val mangaMetadata = db.getFlatMetadataForManga(track.manga_id).executeAsBlocking()
?.raise<MangaDexSearchMetadata>()
?: throw Exception("Invalid manga metadata")
val followStatus = FollowStatus.fromInt(track.status) ?: throw Exception("Follow status was not a valid value")
val followStatus = FollowStatus.fromInt(track.status)
// allow follow status to update
if (mangaMetadata.follow_status != followStatus.int) {
@ -71,6 +71,14 @@ class MdList(private val context: Context, id: Int) : TrackService(id) {
if (followStatus != FollowStatus.UNFOLLOWED) {
if (track.total_chapters != 0 && track.last_chapter_read == track.total_chapters) {
track.status = FollowStatus.COMPLETED.int
mdex.updateFollowStatus(MdUtil.getMangaId(track.tracking_url), FollowStatus.COMPLETED)
}
if (followStatus == FollowStatus.PLAN_TO_READ && track.last_chapter_read > 0) {
val newFollowStatus = FollowStatus.READING
track.status = FollowStatus.READING.int
mdex.updateFollowStatus(MdUtil.getMangaId(track.tracking_url), newFollowStatus)
mangaMetadata.follow_status = newFollowStatus.int
db.insertFlatMetadata(mangaMetadata.flatten()).await()
}
mdex.updateReadingProgress(track)

View File

@ -10,6 +10,6 @@ enum class FollowStatus(val int: Int) {
RE_READING(6);
companion object {
fun fromInt(value: Int): FollowStatus = FollowStatus.values().find { it.int == value } ?: UNFOLLOWED
fun fromInt(value: Int): FollowStatus = values().find { it.int == value } ?: UNFOLLOWED
}
}