mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-10-30 23:51:57 +01:00
fix(android): a chosen server starts fresh, without the last one behind it
Found on a real device: after Change server, Back did not offer the leave prompt but reversed into the previous server's pages, leaving the app showing one instance while it was set to another. The address form is reached through Back, so switching twice was enough to get there. The behaviour predates the recent-servers list, but that list is what turns switching servers into an everyday action rather than a once-a-year one. Only a deliberate choice of server clears the history - typed in, picked from the list, or restored at startup. Following a notification into a conversation still goes back the way it came. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b40a28c3b4
commit
9adb98dfdd
3 files changed
+25
No files matched your search
Binary file not shown.
@@ -94,6 +94,9 @@ class MainActivity : AppCompatActivity() {
|
||||
/** Whether the page now loading has already failed, for [rememberServer]. */
|
||||
private var pageLoadFailed = false
|
||||
|
||||
/** Set by [connect]; drops the pages of whichever server we just left. */
|
||||
private var clearHistoryOnLoad = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
// Before setContentView, as androidx asks. Transparent rather than the
|
||||
@@ -246,9 +249,21 @@ class MainActivity : AppCompatActivity() {
|
||||
applyChromeColor(Color.WHITE)
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a server the user has just chosen - typed in, picked from the list,
|
||||
* or restored at startup.
|
||||
*
|
||||
* The pages of the previous server go with it. Without that, Back walks out
|
||||
* of the server you just picked and into the one before it, leaving the app
|
||||
* showing one server while it is set to another; and the address form is
|
||||
* reached through Back, so switching servers twice used to be enough to get
|
||||
* there. Only a deliberate choice of server clears it - following a
|
||||
* notification into a conversation still goes back the way it came.
|
||||
*/
|
||||
private fun connect(url: String) {
|
||||
configLayout.visibility = View.GONE
|
||||
webView.visibility = View.VISIBLE
|
||||
clearHistoryOnLoad = true
|
||||
webView.loadUrl(url)
|
||||
}
|
||||
|
||||
@@ -453,6 +468,12 @@ class MainActivity : AppCompatActivity() {
|
||||
// Only an address that actually answered is worth offering
|
||||
// again, which is what keeps typos out of the list
|
||||
if (!pageLoadFailed) rememberServer(prefs.getString(KEY_URL, null))
|
||||
if (clearHistoryOnLoad) {
|
||||
clearHistoryOnLoad = false
|
||||
// Documented as unreliable before the first page settles,
|
||||
// which is exactly what onPageFinished waits for
|
||||
view?.clearHistory()
|
||||
}
|
||||
}
|
||||
|
||||
// Deprecated, but it is the only one Android 5.x calls
|
||||
|
||||
@@ -168,6 +168,10 @@ actually answered — a mistyped address never joins it. If you run a single
|
||||
instance you will simply see it listed there on its own, and nothing about the
|
||||
form changes.
|
||||
|
||||
Connecting to a server this way starts it fresh: **Back** brings up the leave
|
||||
prompt again rather than reversing into the pages of the server you just left.
|
||||
Otherwise the app would end up showing one instance while it is set to another.
|
||||
|
||||
### Servers that ask for a password
|
||||
|
||||
If your instance sits behind a reverse proxy configured to require a login
|
||||
|
||||
Reference in new issue
Block a user