fix: preloader + update notification robustness
- Add full-screen CSS preloader to webapp (fades out when _initApp completes) - Defer _checkWebappUpdate() to 6s after app init so it does not compete with startup API calls (fixes perceived slowness on first load) - Switch update-check throttle from sessionStorage to localStorage (6h TTL); use release published_at instead of version string for comparison, so the banner correctly appears when a new release is published regardless of whether the tag is a semver or the rolling "latest" tag - PHP _isLatestVersion(): return true (do not suppress error reports) when tag_name is non-semver (e.g. "latest") — was incorrectly blocking ALL reports - Kiosk checkForUpdates(): show banner only when the release asset actually contains an APK for the component; handle non-semver tag by treating it as always-update (prevents silent no-op with rolling "latest" tag) - Scale gateway checkForUpdates(): same non-semver fix; apkUrl now defaults to empty and bails out if no matching APK found in assets (prevents 404 install)
This commit is contained in:
+9
-3
@@ -427,10 +427,10 @@ class MainActivity : AppCompatActivity(), BleScaleListener, ServerEventListener
|
||||
val latestTag = json.optString("tag_name", "").ifEmpty { return@Thread }
|
||||
val current = try { packageManager.getPackageInfo(packageName, 0).versionName ?: "" } catch (_: Exception) { "" }
|
||||
val norm = { v: String -> v.trimStart('v') }
|
||||
if (norm(latestTag) == norm(current)) return@Thread // already up to date
|
||||
val isSemver = latestTag.trimStart('v').matches(Regex("\\d+\\.\\d+.*"))
|
||||
|
||||
// Find scale-gateway APK in release assets
|
||||
var apkUrl = APK_DOWNLOAD_URL
|
||||
var apkUrl = ""
|
||||
val assets = json.optJSONArray("assets")
|
||||
if (assets != null) {
|
||||
for (i in 0 until assets.length()) {
|
||||
@@ -442,7 +442,13 @@ class MainActivity : AppCompatActivity(), BleScaleListener, ServerEventListener
|
||||
}
|
||||
}
|
||||
}
|
||||
val msg = "⬆️ Scale Gateway $current → $latestTag"
|
||||
// Only show banner if the release actually contains our APK
|
||||
if (apkUrl.isEmpty()) return@Thread
|
||||
// If semver tag matches current version → already up to date
|
||||
if (isSemver && norm(latestTag) == norm(current)) return@Thread
|
||||
|
||||
val label = if (isSemver) "$current → $latestTag" else latestTag
|
||||
val msg = "⬆️ Scale Gateway $label"
|
||||
runOnUiThread { showNativeUpdateBanner(msg, apkUrl) }
|
||||
} catch (_: Exception) {}
|
||||
}.start()
|
||||
|
||||
Reference in New Issue
Block a user