Skip to content

Commit 924098b

Browse files
authored
Merge pull request libre-tube#7143 from Bnyro/master
fix: update checker doesn't detect new releases properly
2 parents 387933c + 8f685ed commit 924098b

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

app/src/main/java/com/github/libretube/util/UpdateChecker.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ import java.util.Locale
1818

1919
class UpdateChecker(private val context: Context) {
2020
suspend fun checkUpdate(isManualCheck: Boolean = false) {
21-
val currentAppVersion = BuildConfig.VERSION_NAME.replace(".", "").toInt()
21+
val currentAppVersion = BuildConfig.VERSION_NAME.filter { it.isDigit() }.toInt()
2222

2323
try {
2424
val response = RetrofitInstance.externalApi.getLatestRelease()
2525
// version would be in the format "0.21.1"
26-
val update = response.name.replace(".", "").toIntOrNull()
26+
val update = response.name.filter { it.isDigit() }.toInt()
2727

28-
if (update != null && currentAppVersion < update) {
28+
if (currentAppVersion != update) {
2929
withContext(Dispatchers.Main) {
3030
showUpdateAvailableDialog(response.body, response.htmlUrl)
3131
}
@@ -56,15 +56,15 @@ class UpdateChecker(private val context: Context) {
5656
}
5757

5858
private fun sanitizeChangelog(changelog: String): String {
59-
val removeBloat = changelog.substringBeforeLast("**Full Changelog**")
60-
val removeLinks = removeBloat.replace(Regex("in https://github\\.com/\\S+"), "")
61-
val uppercaseChangeType =
62-
removeLinks.lines().joinToString("\n") { line ->
59+
return changelog.substringBeforeLast("**Full Changelog**")
60+
.replace(Regex("in https://github\\.com/\\S+"), "")
61+
.lines().joinToString("\n") { line ->
6362
if (line.startsWith("##")) line.uppercase(Locale.ROOT) + " :" else line
6463
}
65-
val removeHashes = uppercaseChangeType.replace("## ", "")
66-
val cleanPrefix = removeHashes.replace("*", "")
67-
68-
return cleanPrefix.trim()
64+
.replace("## ", "")
65+
.replace(">", "")
66+
.replace("*", "")
67+
.lines()
68+
.joinToString("\n") { it.trim() }
6969
}
7070
}

0 commit comments

Comments
 (0)