Skip to content

Commit

Permalink
Correctly check if a new version is available for the preview channel (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
schroda authored Jul 21, 2023
1 parent e920615 commit 2ce423b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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" }
Expand Down

0 comments on commit 2ce423b

Please sign in to comment.