Comick.fun: Fix parsing issue for nullable chapter numbers (#7902)
This commit is contained in:
parent
4a8a87a80f
commit
72fd4cc564
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Comick.fun'
|
extName = 'Comick.fun'
|
||||||
pkgNameSuffix = 'all.comickfun'
|
pkgNameSuffix = 'all.comickfun'
|
||||||
extClass = '.ComickFunFactory'
|
extClass = '.ComickFunFactory'
|
||||||
extVersionCode = 4
|
extVersionCode = 5
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
containsNsfw = true
|
containsNsfw = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,25 +46,23 @@ inline fun <reified T : Any> deepSelectDeserializer(vararg keys: String, tDeseri
|
||||||
buildClassSerialDescriptor("$x\$${it.serialName}") { element(x, it) }
|
buildClassSerialDescriptor("$x\$${it.serialName}") { element(x, it) }
|
||||||
}
|
}
|
||||||
}.asReversed()
|
}.asReversed()
|
||||||
var a: ((Int) -> KSerializer<T>)? = null
|
|
||||||
val b = { depth: Int ->
|
return object : KSerializer<T> {
|
||||||
object : KSerializer<T> {
|
private var depth = 0
|
||||||
override val descriptor = descriptors[depth]
|
private fun <S> asChild(fn: (KSerializer<T>) -> S) = fn(this.apply { depth += 1 }).also { depth -= 1 }
|
||||||
|
override val descriptor get() = descriptors[depth]
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): T {
|
override fun deserialize(decoder: Decoder): T {
|
||||||
return if (depth == keys.size) decoder.decodeSerializableValue(tDeserializer)
|
return if (depth == keys.size) decoder.decodeSerializableValue(tDeserializer)
|
||||||
else decoder.decodeStructureByKnownName(descriptor) { names ->
|
else decoder.decodeStructureByKnownName(descriptor) { names ->
|
||||||
names.filter { (name, _) -> name == keys[depth] }
|
names.filter { (name, _) -> name == keys[depth] }
|
||||||
.map { (_, index) -> decodeSerializableElement(descriptor, index, a!!(depth + 1)) }
|
.map { (_, index) -> asChild { decodeSerializableElement(descriptors[depth - 1]/* find something more elegant */, index, it) } }
|
||||||
.single()
|
.single()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, value: T) = throw UnsupportedOperationException("Not supported")
|
override fun serialize(encoder: Encoder, value: T) = throw UnsupportedOperationException("Not supported")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
a = b // this is the hackiest of hacky hacks to get around not being able to define recursive inline functions
|
|
||||||
return a(0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,8 +155,8 @@ class SChapterDeserializer : KSerializer<SChapter> {
|
||||||
"title" -> title = decodeNullableSerializableElement(descriptor, index, serializer())
|
"title" -> title = decodeNullableSerializableElement(descriptor, index, serializer())
|
||||||
"vol" -> vol = decodeNullableSerializableElement(descriptor, index, serializer())
|
"vol" -> vol = decodeNullableSerializableElement(descriptor, index, serializer())
|
||||||
"chap" -> {
|
"chap" -> {
|
||||||
chap = decodeStringElement(descriptor, index)
|
chap = decodeNullableSerializableElement(descriptor, index, serializer())
|
||||||
chapter_number = chap!!.toFloat()
|
chapter_number = chap?.toFloat() ?: -1f
|
||||||
}
|
}
|
||||||
"hid" -> hid = decodeStringElement(descriptor, index)
|
"hid" -> hid = decodeStringElement(descriptor, index)
|
||||||
"iso639_1" -> iso639_1 = decodeStringElement(descriptor, index)
|
"iso639_1" -> iso639_1 = decodeStringElement(descriptor, index)
|
||||||
|
|
Loading…
Reference in New Issue