mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix: Crashes cause by Bangumi invalid status
This commit is contained in:
parent
57fe8e8ae3
commit
f9a7589fe9
3 changed files with 5 additions and 2 deletions
|
@ -146,7 +146,7 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept
|
|||
null
|
||||
} else {
|
||||
json.decodeFromString<Collection>(responseBody).let {
|
||||
track.status = it.status?.id!!
|
||||
track.status = it.status?.id ?: Bangumi.DEFAULT_STATUS
|
||||
track.last_chapter_read = it.ep_status!!.toFloat()
|
||||
track.score = it.rating!!
|
||||
track
|
||||
|
|
|
@ -8,6 +8,9 @@ fun Track.toBangumiStatus() = when (status) {
|
|||
Bangumi.ON_HOLD -> "on_hold"
|
||||
Bangumi.DROPPED -> "dropped"
|
||||
Bangumi.PLAN_TO_READ -> "wish"
|
||||
// Caused by status being null somehow when a manga is being tracked for
|
||||
// the first time.
|
||||
0 -> "do"
|
||||
else -> throw NotImplementedError("Unknown status: $status")
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import kotlinx.serialization.Serializable
|
|||
|
||||
@Serializable
|
||||
data class Status(
|
||||
val id: Int? = 0,
|
||||
val id: Int? = null,
|
||||
val name: String? = "",
|
||||
val type: String? = "",
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue