[MyAnimeList] Handle cases where my_list_status.status is not present (#8931)

This commit is contained in:
beerpsi 2023-01-17 09:59:07 +07:00 committed by GitHub
parent dc2d470413
commit b7e6b4c28a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -208,7 +208,7 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
val obj = response.jsonObject
return track.apply {
val isRereading = obj["is_rereading"]!!.jsonPrimitive.boolean
status = if (isRereading) MyAnimeList.REREADING else getStatus(obj["status"]!!.jsonPrimitive.content)
status = if (isRereading) MyAnimeList.REREADING else getStatus(obj["status"]?.jsonPrimitive?.content)
last_chapter_read = obj["num_chapters_read"]!!.jsonPrimitive.float
score = obj["score"]!!.jsonPrimitive.int.toFloat()
obj["start_date"]?.let {

View File

@ -24,7 +24,7 @@ fun Track.toMyAnimeListStatus() = when (status) {
else -> null
}
fun getStatus(status: String) = when (status) {
fun getStatus(status: String?) = when (status) {
"reading" -> MyAnimeList.READING
"completed" -> MyAnimeList.COMPLETED
"on_hold" -> MyAnimeList.ON_HOLD