Skip to content

Commit

Permalink
app: Fix crash when no changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Oct 30, 2024
1 parent d338b14 commit 0a781d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
4 changes: 3 additions & 1 deletion composeApp/src/commonMain/kotlin/misc/AppUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ fun handleRomInfo(
) {
if (romInfo?.bigversion != null) {
val log = StringBuilder()
romInfo.changelog!!.forEach { log.append(it.key).append("\n").append(it.value.txt.joinToString("\n")).append("\n\n") }
if (romInfo.changelog != null) {
romInfo.changelog.forEach { log.append(it.key).append("\n").append(it.value.txt.joinToString("\n")).append("\n\n") }
}
val changelogGroups = log.toString().trimEnd().split("\n\n")
val changelog = changelogGroups.map { it.split("\n").drop(1).joinToString("\n") }
val iconNames = changelogGroups.map { it.split("\n").first() }
Expand Down
24 changes: 10 additions & 14 deletions composeApp/src/commonMain/kotlin/ui/InfoCardViews.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,12 @@ fun InfoCardViews(
modifier = Modifier.weight(1f),
"ultimateota",
romInfoState.value.official1Download,
romInfoState.value.official1Download,
romInfoState.value.fileName
)
DownloadInfoView(
modifier = Modifier.weight(1f),
"superota",
romInfoState.value.official2Download,
romInfoState.value.official2Download,
romInfoState.value.fileName
)
}
Expand All @@ -127,22 +125,21 @@ fun InfoCardViews(
modifier = Modifier.weight(1f),
"cdnorg",
romInfoState.value.cdn1Download,
romInfoState.value.cdn1Download,
romInfoState.value.fileName
)
DownloadInfoView(
modifier = Modifier.weight(1f),
"aliyuncs",
romInfoState.value.cdn2Download,
romInfoState.value.cdn2Download,
romInfoState.value.fileName
)
}

ChangelogView(
iconInfo,
romInfoState.value.changelog
)
if (romInfoState.value.changelog.isNotEmpty()) {
ChangelogView(
iconInfo,
romInfoState.value.changelog
)
}
}
}
}
Expand Down Expand Up @@ -201,8 +198,7 @@ fun MessageTextView(
fun DownloadInfoView(
modifier: Modifier = Modifier,
title: String,
copy: String,
download: String,
url: String,
fileName: String
) {
val hapticFeedback = LocalHapticFeedback.current
Expand All @@ -220,10 +216,10 @@ fun DownloadInfoView(
textAlign = TextAlign.Center
)
Row {
if (copy.isNotEmpty()) {
if (url.isNotEmpty()) {
IconButton(
onClick = {
copyToClipboard(copy)
copyToClipboard(url)
showMessage(messageCopySuccessful)
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
}
Expand All @@ -236,7 +232,7 @@ fun DownloadInfoView(
}
IconButton(
onClick = {
downloadToLocal(download, fileName)
downloadToLocal(url, fileName)
showMessage(messageDownloadStart)
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
}
Expand Down

0 comments on commit 0a781d9

Please sign in to comment.