Rename MangaDex's FollowStatus's property to better reflect its type (#1082)

This commit is contained in:
Cuong M. Tran
2024-03-02 23:56:11 +07:00
committed by GitHub
parent 94e5c33785
commit dd412e33ad
7 changed files with 27 additions and 27 deletions
@@ -57,7 +57,7 @@ class FollowsHandler(
it,
lang,
) to MangaDexSearchMetadata().apply {
followStatus = FollowStatus.fromDex(statuses[it.id]).int.toInt()
followStatus = FollowStatus.fromDex(statuses[it.id]).long.toInt()
}
}.sortedWith(comparator)
}
@@ -155,7 +155,7 @@ class FollowsHandler(
val (followStatus, rating) = followStatusDef.await() to ratingDef.await()
Track.create(TrackerManager.MDLIST).apply {
title = ""
status = followStatus.int
status = followStatus.long
tracking_url = url
score = rating?.rating?.toDouble() ?: 0.0
}
@@ -2,14 +2,14 @@ package exh.md.utils
import java.util.Locale
enum class FollowStatus(val int: Long) {
UNFOLLOWED(0),
READING(1),
COMPLETED(2),
ON_HOLD(3),
PLAN_TO_READ(4),
DROPPED(5),
RE_READING(6),
enum class FollowStatus(val long: Long) {
UNFOLLOWED(0L),
READING(1L),
COMPLETED(2L),
ON_HOLD(3L),
PLAN_TO_READ(4L),
DROPPED(5L),
RE_READING(6L),
;
fun toDex(): String = this.name.lowercase(Locale.US)
@@ -18,6 +18,6 @@ enum class FollowStatus(val int: Long) {
fun fromDex(
value: String?,
): FollowStatus = entries.firstOrNull { it.name.lowercase(Locale.US) == value } ?: UNFOLLOWED
fun fromInt(value: Long): FollowStatus = entries.firstOrNull { it.int == value } ?: UNFOLLOWED
fun fromLong(value: Long): FollowStatus = entries.firstOrNull { it.long == value } ?: UNFOLLOWED
}
}