mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-16 13:48:09 -07:00
Don't send full Doubles to Comick for progress (#4090)
Previously, user could end up with progress displays like
35.019996643066406/100
because Mihon was sending raw Doubles/simply stringified Doubles for
progress data.
We now round to 2 decimal places & trim off any trailing zeroes such
that integers are sent as "1" instead of "1.0" while retaining "25.5"
and "41.02" as such.
(cherry picked from commit 1ca9b0efb8)
This commit is contained in:
@@ -12,6 +12,9 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
- Fix long floating point numbers showing up in Comick progress ([@MajorTanya](https://github.com/MajorTanya)) ([#4090](https://github.com/mihonapp/mihon/pull/4090))
|
||||
|
||||
## [v0.21.1] - 2026-10-12
|
||||
### Fixed
|
||||
- Fixed refreshing chapters failing with the app language set to Arabic or another language with its own digits ([@AntsyLich](https://github.com/AntsyLich)) ([`8457fb9`](https://github.com/mihonapp/mihon/commit/8457fb9))
|
||||
|
||||
@@ -33,6 +33,7 @@ import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.math.RoundingMode
|
||||
import java.security.SecureRandom
|
||||
import java.util.Base64
|
||||
import kotlin.time.Duration.Companion.minutes
|
||||
@@ -77,7 +78,14 @@ class ComickApi(
|
||||
put("status", track.status.toApiListStatus())
|
||||
if (track.last_chapter_read > 0) {
|
||||
putJsonObject("progress") {
|
||||
put("number", track.last_chapter_read)
|
||||
put(
|
||||
"number",
|
||||
track.last_chapter_read
|
||||
.toBigDecimal()
|
||||
.setScale(2, RoundingMode.HALF_UP)
|
||||
.stripTrailingZeros()
|
||||
.toPlainString(),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
put("progress", null)
|
||||
@@ -140,7 +148,14 @@ class ComickApi(
|
||||
put("rating", track.score.toInt().takeIf { it > 0 })
|
||||
put("status", track.status.toApiListStatus())
|
||||
putJsonObject("progress") {
|
||||
put("number", track.last_chapter_read.toString())
|
||||
put(
|
||||
"number",
|
||||
track.last_chapter_read
|
||||
.toBigDecimal()
|
||||
.setScale(2, RoundingMode.HALF_UP)
|
||||
.stripTrailingZeros()
|
||||
.toPlainString(),
|
||||
)
|
||||
}
|
||||
}
|
||||
.toString()
|
||||
|
||||
Reference in New Issue
Block a user