From e332a5018e5222852e20df7e8ceec59f223c1f1f Mon Sep 17 00:00:00 2001 From: Lorg0n Date: Tue, 22 Oct 2024 18:59:57 +0300 Subject: [PATCH] fix: corrected function names and added reread logic --- .../java/eu/kanade/tachiyomi/data/track/hikka/Hikka.kt | 2 +- .../eu/kanade/tachiyomi/data/track/hikka/HikkaApi.kt | 9 +++++++-- .../tachiyomi/data/track/hikka/HikkaInterceptor.kt | 1 + .../eu/kanade/tachiyomi/data/track/hikka/HikkaUtils.kt | 7 +++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/Hikka.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/Hikka.kt index 7512728f5..ad93c5846 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/Hikka.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/Hikka.kt @@ -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() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaApi.kt index 72fd8c755..a537a4711 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaApi.kt @@ -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()) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaInterceptor.kt index 886b73ac8..db19db4ea 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaInterceptor.kt @@ -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)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaUtils.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaUtils.kt index 42a3b0f16..a4363c128 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaUtils.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaUtils.kt @@ -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 {