mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
fix: fixed a bug where the server returned a 404 error due to receiving data in HikkaApi
This commit is contained in:
parent
6b8c2dcdc3
commit
45cd945f7c
1 changed files with 11 additions and 10 deletions
|
@ -4,8 +4,8 @@ import android.net.Uri
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import eu.kanade.tachiyomi.data.database.models.Track
|
import eu.kanade.tachiyomi.data.database.models.Track
|
||||||
import eu.kanade.tachiyomi.data.track.hikka.dto.HKAuthTokenInfo
|
import eu.kanade.tachiyomi.data.track.hikka.dto.HKAuthTokenInfo
|
||||||
import eu.kanade.tachiyomi.data.track.hikka.dto.HKMangaPagination
|
|
||||||
import eu.kanade.tachiyomi.data.track.hikka.dto.HKManga
|
import eu.kanade.tachiyomi.data.track.hikka.dto.HKManga
|
||||||
|
import eu.kanade.tachiyomi.data.track.hikka.dto.HKMangaPagination
|
||||||
import eu.kanade.tachiyomi.data.track.hikka.dto.HKOAuth
|
import eu.kanade.tachiyomi.data.track.hikka.dto.HKOAuth
|
||||||
import eu.kanade.tachiyomi.data.track.hikka.dto.HKRead
|
import eu.kanade.tachiyomi.data.track.hikka.dto.HKRead
|
||||||
import eu.kanade.tachiyomi.data.track.hikka.dto.HKUser
|
import eu.kanade.tachiyomi.data.track.hikka.dto.HKUser
|
||||||
|
@ -100,17 +100,18 @@ class HikkaApi(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getRead(track: Track): HKRead {
|
private suspend fun getRead(track: Track): HKRead? {
|
||||||
return withIOContext {
|
return withIOContext {
|
||||||
val slug = track.tracking_url.split("/")[4]
|
val slug = track.tracking_url.split("/")[4]
|
||||||
|
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon().build()
|
||||||
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon()
|
|
||||||
.build()
|
|
||||||
|
|
||||||
with(json) {
|
with(json) {
|
||||||
authClient.newCall(GET(url.toString()))
|
val response = authClient.newCall(GET(url.toString())).execute()
|
||||||
.awaitSuccess()
|
if (response.code == 404) {
|
||||||
.parseAs<HKRead>()
|
return@withIOContext null
|
||||||
|
}
|
||||||
|
response.use {
|
||||||
|
it.parseAs<HKRead>()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +151,7 @@ class HikkaApi(
|
||||||
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon()
|
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon()
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
var rereads = getRead(track).rereads
|
var rereads = getRead(track)?.rereads ?: 0
|
||||||
if (track.status == Hikka.REREADING && rereads == 0) {
|
if (track.status == Hikka.REREADING && rereads == 0) {
|
||||||
rereads = 1
|
rereads = 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue