fix: recode the rereading logic in HikkaApi

This commit is contained in:
Lorg0n 2024-10-27 02:14:17 +03:00
parent 23a34cd3b7
commit 6b8c2dcdc3

View File

@ -100,6 +100,21 @@ class HikkaApi(
}
}
private suspend fun getRead(track: Track): HKRead {
return withIOContext {
val slug = track.tracking_url.split("/")[4]
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon()
.build()
with(json) {
authClient.newCall(GET(url.toString()))
.awaitSuccess()
.parseAs<HKRead>()
}
}
}
suspend fun getManga(track: Track): TrackSearch {
return withIOContext {
val slug = track.tracking_url.split("/")[4]
@ -135,10 +150,10 @@ class HikkaApi(
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon()
.build()
var rereads = 0
if (track.status == Hikka.REREADING)
var rereads = getRead(track).rereads
if (track.status == Hikka.REREADING && rereads == 0) {
rereads = 1
}
val payload = buildJsonObject {
put("note", "")