Fallback to the default version of LiveInformation on decode failure

This commit is contained in:
Yasan Ghaffarian
2025-03-20 23:13:43 +01:00
parent d912b54254
commit 16747b5bda
@@ -45,7 +45,8 @@ class LiveInformationManager private constructor(context: Context) : PreferenceM
defaultValue = LiveInformation(),
parse = { string ->
val withUnknownKeys = Json { ignoreUnknownKeys = true }
withUnknownKeys.decodeFromString<LiveInformation>(string)
runCatching { withUnknownKeys.decodeFromString<LiveInformation>(string) }
.getOrNull() ?: LiveInformation()
},
save = { liveInformation ->
Json.encodeToString(