mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-08-06 08:43:17 +02:00
fix: refill the message gap left by a backgrounded app
The chat view only ever grew by socket push, so anything that arrived while the connection was down was never drawn. Android tears the connection down behind a locked screen, and the wrapper keeps the same page alive for days, so the list stopped at the last message that got through until the app was force-stopped. A browser tab hid the same bug by reloading the page on resume. Every way back from a gap now re-reads the list from the server: the socket reconnecting, the page becoming visible after more than a glance away, a heartbeat noticing its own tick arrived far too late (the page was frozen), a new Refresh item in the menu, and window.__mcAppResumed, which the wrapper calls from onResume since a WebView is not guaranteed to report the page as hidden at all. Direct messages get the same treatment. Verified in Chrome against the local container: all five triggers fire a resync, with no page errors and the list intact afterwards. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,8 +11,8 @@ android {
|
||||
applicationId = "it.wojtaszek.mc.wrapper"
|
||||
minSdk = 21
|
||||
targetSdk = 34
|
||||
versionCode = 2
|
||||
versionName = "1.1"
|
||||
versionCode = 3
|
||||
versionName = "1.2"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -106,6 +106,18 @@ class MainActivity : AppCompatActivity() {
|
||||
if (savedUrl.isNullOrEmpty()) showConfig(null) else connect(savedUrl)
|
||||
}
|
||||
|
||||
/**
|
||||
* The page keeps running while the app sits in the background - that is how
|
||||
* notifications keep arriving - but the connection behind it does not
|
||||
* survive doze, so the message list can be minutes behind by the time the
|
||||
* user looks at it again. A WebView is not guaranteed to tell the page it
|
||||
* was ever hidden, so say it here instead and let mc-webui catch up.
|
||||
*/
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
callJs("window.__mcAppResumed")
|
||||
}
|
||||
|
||||
/**
|
||||
* A notification tap on a running app lands here rather than in [onCreate].
|
||||
* When the app was not running, simply being launched is the whole point of
|
||||
|
||||
Reference in New Issue
Block a user