forked from Louvorg/ReaderForSelfoss-multiplatform
chore: can links be empty ?
This commit is contained in:
@ -2,6 +2,7 @@ package bou.amine.apps.readerforselfossv2.model
|
||||
|
||||
import bou.amine.apps.readerforselfossv2.utils.DateUtils
|
||||
import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded
|
||||
import bou.amine.apps.readerforselfossv2.utils.isEmptyOrNullOrNullString
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.descriptors.PrimitiveKind
|
||||
@ -10,7 +11,12 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.encoding.encodeCollection
|
||||
import kotlinx.serialization.json.*
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.JsonDecoder
|
||||
import kotlinx.serialization.json.boolean
|
||||
import kotlinx.serialization.json.booleanOrNull
|
||||
import kotlinx.serialization.json.int
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
|
||||
class SelfossModel {
|
||||
@Serializable
|
||||
@ -134,6 +140,10 @@ class SelfossModel {
|
||||
stringUrl = "http:$stringUrl"
|
||||
}
|
||||
|
||||
if (stringUrl.isEmptyOrNullOrNullString()) {
|
||||
throw Exception("Link ${link} was translated to ${stringUrl}, but was empty. Handle this.")
|
||||
}
|
||||
|
||||
return stringUrl
|
||||
}
|
||||
|
||||
@ -176,7 +186,10 @@ class SelfossModel {
|
||||
encoder: Encoder,
|
||||
value: List<String>,
|
||||
) {
|
||||
encoder.encodeCollection(PrimitiveSerialDescriptor("tags", PrimitiveKind.STRING), value.size) { this.toString() }
|
||||
encoder.encodeCollection(
|
||||
PrimitiveSerialDescriptor("tags", PrimitiveKind.STRING),
|
||||
value.size
|
||||
) { this.toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +204,10 @@ class SelfossModel {
|
||||
}
|
||||
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = PrimitiveSerialDescriptor("BooleanOrIntForSomeSelfossVersions", PrimitiveKind.BOOLEAN)
|
||||
get() = PrimitiveSerialDescriptor(
|
||||
"BooleanOrIntForSomeSelfossVersions",
|
||||
PrimitiveKind.BOOLEAN
|
||||
)
|
||||
|
||||
override fun serialize(
|
||||
encoder: Encoder,
|
||||
@ -200,4 +216,4 @@ class SelfossModel {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user