mirror of
https://github.com/mihonapp/mihon.git
synced 2025-01-12 19:27:16 +01:00
fix: corrected function names and added reread logic
This commit is contained in:
parent
41db4a5865
commit
e332a5018e
@ -142,7 +142,7 @@ class Hikka(id: Long) : BaseTracker(id, "Hikka"), DeletableTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun delete(track: Track) {
|
override suspend fun delete(track: Track) {
|
||||||
api.deleteManga(track)
|
api.deleteUserManga(track)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun logout() {
|
override fun logout() {
|
||||||
|
@ -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 {
|
return withIOContext {
|
||||||
val slug = track.remoteUrl.split("/")[4]
|
val slug = track.remoteUrl.split("/")[4]
|
||||||
|
|
||||||
@ -135,11 +135,16 @@ 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 = 0
|
||||||
|
|
||||||
|
if (track.status == Hikka.REREADING)
|
||||||
|
rereads = 1
|
||||||
|
|
||||||
val payload = buildJsonObject {
|
val payload = buildJsonObject {
|
||||||
put("note", "")
|
put("note", "")
|
||||||
put("chapters", track.last_chapter_read.toInt())
|
put("chapters", track.last_chapter_read.toInt())
|
||||||
put("volumes", 0)
|
put("volumes", 0)
|
||||||
put("rereads", 0)
|
put("rereads", rereads)
|
||||||
put("score", track.score.toInt())
|
put("score", track.score.toInt())
|
||||||
put("status", track.toApiStatus())
|
put("status", track.toApiStatus())
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ class HikkaInterceptor(private val hikka: Hikka) : Interceptor {
|
|||||||
if (currAuth.isExpired()) {
|
if (currAuth.isExpired()) {
|
||||||
val refreshTokenResponse = chain.proceed(HikkaApi.refreshTokenRequest(currAuth.accessToken))
|
val refreshTokenResponse = chain.proceed(HikkaApi.refreshTokenRequest(currAuth.accessToken))
|
||||||
if (!refreshTokenResponse.isSuccessful)
|
if (!refreshTokenResponse.isSuccessful)
|
||||||
|
throw Exception("Hikka: The token is expired")
|
||||||
refreshTokenResponse.close()
|
refreshTokenResponse.close()
|
||||||
|
|
||||||
val authTokenInfoResponse = chain.proceed(HikkaApi.authTokenInfo(currAuth.accessToken))
|
val authTokenInfoResponse = chain.proceed(HikkaApi.authTokenInfo(currAuth.accessToken))
|
||||||
|
@ -9,8 +9,8 @@ fun Track.toApiStatus() = when (status) {
|
|||||||
Hikka.ON_HOLD -> "on_hold"
|
Hikka.ON_HOLD -> "on_hold"
|
||||||
Hikka.DROPPED -> "dropped"
|
Hikka.DROPPED -> "dropped"
|
||||||
Hikka.PLAN_TO_READ -> "planned"
|
Hikka.PLAN_TO_READ -> "planned"
|
||||||
Hikka.REREADING -> "completed"
|
Hikka.REREADING -> "reading"
|
||||||
else -> throw NotImplementedError("To Api: Unknown status: $status")
|
else -> throw NotImplementedError("Hikka: Unknown status: $status")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toTrackStatus(status: String) = when (status) {
|
fun toTrackStatus(status: String) = when (status) {
|
||||||
@ -19,8 +19,7 @@ fun toTrackStatus(status: String) = when (status) {
|
|||||||
"on_hold" -> Hikka.ON_HOLD
|
"on_hold" -> Hikka.ON_HOLD
|
||||||
"dropped" -> Hikka.DROPPED
|
"dropped" -> Hikka.DROPPED
|
||||||
"planned" -> Hikka.PLAN_TO_READ
|
"planned" -> Hikka.PLAN_TO_READ
|
||||||
"rewatching" -> Hikka.REREADING
|
else -> throw NotImplementedError("Hikka: Unknown status: $status")
|
||||||
else -> throw NotImplementedError("To Track: Unknown status: $status")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stringToNumber(input: String): Long {
|
fun stringToNumber(input: String): Long {
|
||||||
|
Loading…
Reference in New Issue
Block a user