Correctly check if a new version is available for the preview channel (#604)

The actual version of the preview was never loaded and compared to the local version.
Instead, for the preview channel it was incorrectly decided that a new version is available on every update check
This commit is contained in:
schroda
2023-07-22 01:51:51 +02:00
committed by GitHub
parent e9206158b8
commit 2ce423b6cb

View File

@@ -251,7 +251,7 @@ object WebInterfaceManager {
private fun fetchPreviewVersion(): String {
val releaseInfoJson = URL(WebUI.WEBUI.latestReleaseInfoUrl).readText()
return Json.decodeFromString<JsonObject>(releaseInfoJson)["tag_name"]?.jsonPrimitive?.content ?: ""
return Json.decodeFromString<JsonObject>(releaseInfoJson)["tag_name"]?.jsonPrimitive?.content ?: throw Exception("Failed to get the preview version tag")
}
private fun getLatestCompatibleVersion(): String {
@@ -385,7 +385,13 @@ object WebInterfaceManager {
fun isUpdateAvailable(currentVersion: String): Boolean {
return try {
val latestCompatibleVersion = getLatestCompatibleVersion()
val version = getLatestCompatibleVersion()
val latestCompatibleVersion = if (version == webUIPreviewVersion) {
fetchPreviewVersion()
} else {
version
}
latestCompatibleVersion != currentVersion
} catch (e: Exception) {
logger.debug { "isUpdateAvailable: check failed due to $e" }