avoid crash with bad xml format (#551)

This commit is contained in:
Cuong-Tran 2024-11-25 07:20:47 +07:00
parent 6d6fb8da77
commit 05a52f2e13
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2

View file

@ -61,13 +61,17 @@ fun WhatsNewDialog(onDismissRequest: () -> Unit) {
Column {
val changelog by produceState<List<DisplayChangelog>?>(initialValue = null) {
value = withIOContext {
XML.decodeFromReader<Changelog>(
AndroidXmlReader(
context.resources.openRawResource(
if (isReleaseBuildType) R.raw.changelog_release else R.raw.changelog_preview,
).bufferedReader(),
),
).toDisplayChangelog()
try {
XML.decodeFromReader<Changelog>(
AndroidXmlReader(
context.resources.openRawResource(
if (isReleaseBuildType) R.raw.changelog_release else R.raw.changelog_preview,
).bufferedReader(),
),
).toDisplayChangelog()
} catch (e: Exception) {
emptyList()
}
}
}
if (changelog != null) {