ref: optimized imports and refactor code

This commit is contained in:
Lorg0n 2024-10-27 15:31:12 +03:00
parent a8f4e63d54
commit f480d4cb38
9 changed files with 30 additions and 24 deletions

View file

@ -12,9 +12,9 @@ import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import tachiyomi.domain.track.model.Track as DomainTrack
import tachiyomi.i18n.MR
import uy.kohesive.injekt.injectLazy
import tachiyomi.domain.track.model.Track as DomainTrack
class Hikka(id: Long) : BaseTracker(id, "Hikka"), DeletableTracker {
@ -51,7 +51,7 @@ class Hikka(id: Long) : BaseTracker(id, "Hikka"), DeletableTracker {
ON_HOLD,
DROPPED,
PLAN_TO_READ,
REREADING
REREADING,
)
}

View file

@ -79,15 +79,21 @@ class HikkaApi(
put("only_translated", false)
put("magazines", buildJsonArray { })
put("genres", buildJsonArray { })
put("score", buildJsonArray {
put(
"score",
buildJsonArray {
add(0)
add(10)
})
},
)
put("query", query)
put("sort", buildJsonArray {
put(
"sort",
buildJsonArray {
add("score:asc")
add("scored_by:asc")
})
},
)
}
with(json) {
@ -103,7 +109,7 @@ 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()
val url = "$BASE_API_URL/read/manga/$slug".toUri().buildUpon().build()
with(json) {
val response = authClient.newCall(GET(url.toString())).execute()
if (response.code == 404) {
@ -120,7 +126,7 @@ class HikkaApi(
return withIOContext {
val slug = track.tracking_url.split("/")[4]
val url = "$BASE_API_URL/manga/${slug}".toUri().buildUpon()
val url = "$BASE_API_URL/manga/$slug".toUri().buildUpon()
.build()
with(json) {
@ -136,7 +142,7 @@ class HikkaApi(
return withIOContext {
val slug = track.remoteUrl.split("/")[4]
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon()
val url = "$BASE_API_URL/read/manga/$slug".toUri().buildUpon()
.build()
authClient.newCall(DELETE(url.toString()))
@ -148,7 +154,7 @@ class HikkaApi(
return withIOContext {
val slug = track.tracking_url.split("/")[4]
val url = "$BASE_API_URL/read/manga/${slug}".toUri().buildUpon()
val url = "$BASE_API_URL/read/manga/$slug".toUri().buildUpon()
.build()
var rereads = getRead(track)?.rereads ?: 0

View file

@ -9,5 +9,5 @@ data class HKAuthTokenInfo(
val client: HKClient,
val scope: List<String>,
val expiration: Long,
val used: Long
val used: Long,
)

View file

@ -10,5 +10,5 @@ data class HKClient(
val verified: Boolean,
val user: HKUser,
val created: Long,
val updated: Long
val updated: Long,
)

View file

@ -21,7 +21,7 @@ data class HKManga(
val year: Int,
@SerialName("scored_by") val scoredBy: Int,
val score: Double,
val slug: String
val slug: String,
) {
fun toTrack(trackId: Long): TrackSearch {
return TrackSearch.create(trackId).apply {

View file

@ -5,5 +5,5 @@ import kotlinx.serialization.Serializable
@Serializable
data class HKMangaPagination(
val pagination: HKPagination,
val list: List<HKManga>
val list: List<HKManga>,
)

View file

@ -6,5 +6,5 @@ import kotlinx.serialization.Serializable
data class HKPagination(
val total: Int,
val pages: Int,
val page: Int
val page: Int,
)

View file

@ -17,7 +17,7 @@ data class HKRead(
val volumes: Int,
val rereads: Int,
val score: Int,
val content: HKManga
val content: HKManga,
) {
fun toTrack(trackId: Long): TrackSearch {
return TrackSearch.create(trackId).apply {

View file

@ -12,5 +12,5 @@ data class HKUser(
val cover: String,
val active: Boolean,
val avatar: String,
val role: String
val role: String,
)