fix: corrected function names and added reread logic

This commit is contained in:
Lorg0n 2024-10-22 18:59:57 +03:00
parent 41db4a5865
commit e332a5018e
4 changed files with 12 additions and 7 deletions

View File

@ -142,7 +142,7 @@ class Hikka(id: Long) : BaseTracker(id, "Hikka"), DeletableTracker {
}
override suspend fun delete(track: Track) {
api.deleteManga(track)
api.deleteUserManga(track)
}
override fun logout() {

View File

@ -116,7 +116,7 @@ class HikkaApi(
}
}
suspend fun deleteManga(track: tachiyomi.domain.track.model.Track) {
suspend fun deleteUserManga(track: tachiyomi.domain.track.model.Track) {
return withIOContext {
val slug = track.remoteUrl.split("/")[4]
@ -135,11 +135,16 @@ class HikkaApi(
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon()
.build()
var rereads = 0
if (track.status == Hikka.REREADING)
rereads = 1
val payload = buildJsonObject {
put("note", "")
put("chapters", track.last_chapter_read.toInt())
put("volumes", 0)
put("rereads", 0)
put("rereads", rereads)
put("score", track.score.toInt())
put("status", track.toApiStatus())
}

View File

@ -19,6 +19,7 @@ class HikkaInterceptor(private val hikka: Hikka) : Interceptor {
if (currAuth.isExpired()) {
val refreshTokenResponse = chain.proceed(HikkaApi.refreshTokenRequest(currAuth.accessToken))
if (!refreshTokenResponse.isSuccessful)
throw Exception("Hikka: The token is expired")
refreshTokenResponse.close()
val authTokenInfoResponse = chain.proceed(HikkaApi.authTokenInfo(currAuth.accessToken))

View File

@ -9,8 +9,8 @@ fun Track.toApiStatus() = when (status) {
Hikka.ON_HOLD -> "on_hold"
Hikka.DROPPED -> "dropped"
Hikka.PLAN_TO_READ -> "planned"
Hikka.REREADING -> "completed"
else -> throw NotImplementedError("To Api: Unknown status: $status")
Hikka.REREADING -> "reading"
else -> throw NotImplementedError("Hikka: Unknown status: $status")
}
fun toTrackStatus(status: String) = when (status) {
@ -19,8 +19,7 @@ fun toTrackStatus(status: String) = when (status) {
"on_hold" -> Hikka.ON_HOLD
"dropped" -> Hikka.DROPPED
"planned" -> Hikka.PLAN_TO_READ
"rewatching" -> Hikka.REREADING
else -> throw NotImplementedError("To Track: Unknown status: $status")
else -> throw NotImplementedError("Hikka: Unknown status: $status")
}
fun stringToNumber(input: String): Long {