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:
parent
4a268de6dc
commit
5fefefcb23
@ -53,7 +53,7 @@ class MdList(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
val mangaMetadata = db.getFlatMetadataForManga(track.manga_id).executeAsBlocking()
|
val mangaMetadata = db.getFlatMetadataForManga(track.manga_id).executeAsBlocking()
|
||||||
?.raise<MangaDexSearchMetadata>()
|
?.raise<MangaDexSearchMetadata>()
|
||||||
?: throw Exception("Invalid manga metadata")
|
?: 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
|
// allow follow status to update
|
||||||
if (mangaMetadata.follow_status != followStatus.int) {
|
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 (followStatus != FollowStatus.UNFOLLOWED) {
|
||||||
if (track.total_chapters != 0 && track.last_chapter_read == track.total_chapters) {
|
if (track.total_chapters != 0 && track.last_chapter_read == track.total_chapters) {
|
||||||
track.status = FollowStatus.COMPLETED.int
|
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)
|
mdex.updateReadingProgress(track)
|
||||||
|
@ -10,6 +10,6 @@ enum class FollowStatus(val int: Int) {
|
|||||||
RE_READING(6);
|
RE_READING(6);
|
||||||
|
|
||||||
companion object {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user