Revert temp fixes, add serialization progurd rules

This reverts commit 543e089982.
This commit is contained in:
Jobobby04
2020-10-13 13:46:20 -04:00
parent 13196a68b1
commit f3fc479020
9 changed files with 52 additions and 31 deletions
@@ -239,7 +239,7 @@ object DebugFunctions {
try {
val id = it.substringBefore(':').toLong()
if (id != source.id) return@mapNotNull null
JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
} catch (t: RuntimeException) {
// Load failed
XLog.e("Failed to load saved search!", t)
@@ -251,7 +251,7 @@ object DebugFunctions {
try {
val id = it.substringBefore(':').toLong()
if (id != newSource.id) return@mapNotNull null
JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
} catch (t: RuntimeException) {
// Load failed
XLog.e("Failed to load saved search!", t)
@@ -278,7 +278,7 @@ object DebugFunctions {
try {
val id = it.substringBefore(':').toLong()
if (id != source.id) return@mapNotNull null
JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
} catch (t: RuntimeException) {
// Load failed
XLog.e("Failed to load saved search!", t)
@@ -290,7 +290,7 @@ object DebugFunctions {
try {
val id = it.substringBefore(':').toLong()
if (id != newSource.id) return@mapNotNull null
JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
} catch (t: RuntimeException) {
// Load failed
XLog.e("Failed to load saved search!", t)
@@ -2,23 +2,10 @@ package exh.savedsearches
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonPrimitive
@Serializable
data class JsonSavedSearch(
val name: String,
val query: String,
val filters: JsonArray
) {
companion object {
fun fromJsonObject(json: JsonObject): JsonSavedSearch {
return JsonSavedSearch(
json["name"]!!.jsonPrimitive.content,
json["query"]!!.jsonPrimitive.content,
json["filters"]!!.jsonArray,
)
}
}
}
)