feat: return to the add form when a connection fails
A failed connect from the add/edit form reopens it with the typed values and the error, instead of dropping back to the list. Far more useful when the address is wrong. Bump version to 0.1.4 (build 5).
This commit is contained in:
1 parent
265145af41
commit
5db948b36b
3 files changed
+21
-2
No files matched your search
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "OpenChamber",
|
||||
"id": "com.openchamber.native",
|
||||
"version": "0.1.3",
|
||||
"build": 4,
|
||||
"version": "0.1.4",
|
||||
"build": 5,
|
||||
"orientations": ["portrait", "landscape"]
|
||||
}
|
||||
@@ -58,6 +58,7 @@ type controller struct {
|
||||
errorMsg *signal.Signal[string]
|
||||
|
||||
formOpen *signal.Signal[bool]
|
||||
formConnecting bool
|
||||
formEditID string
|
||||
formLabel *signal.Signal[string]
|
||||
formUseProxy *signal.Signal[bool]
|
||||
@@ -173,6 +174,12 @@ func (c *controller) establish(conn storage.Connection, password string, explici
|
||||
ui.Post(func() {
|
||||
c.connecting.Set("")
|
||||
c.errorMsg.Set(friendlyError(err))
|
||||
if c.formConnecting {
|
||||
// The connect came from the add/edit form: bring it back
|
||||
// with what the user typed so it can be fixed.
|
||||
c.formConnecting = false
|
||||
c.formOpen.Set(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
if !strings.Contains(conn.URL, "://") {
|
||||
@@ -296,6 +303,7 @@ func (c *controller) establish(conn storage.Connection, password string, explici
|
||||
c.server.Set(info)
|
||||
c.connected.Set(true)
|
||||
c.busy.Set(false)
|
||||
c.formConnecting = false
|
||||
c.formOpen.Set(false)
|
||||
c.passwordOpen.Set(false)
|
||||
c.passwordText.Set("")
|
||||
@@ -474,6 +482,7 @@ func (c *controller) submitForm() {
|
||||
c.formOpen.Set(false)
|
||||
|
||||
if !c.connected.Peek() {
|
||||
c.formConnecting = true
|
||||
c.connectTo(conn, "", true)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -316,3 +316,13 @@ func TestLabelFallsBackToHost(t *testing.T) {
|
||||
t.Fatalf("label = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFailedAddReopensTheForm(t *testing.T) {
|
||||
a := mount(t, &memStore{})
|
||||
a.Tap("手动输入地址")
|
||||
a.Type("http://192.168.1.5:3000", "http://127.0.0.1:1")
|
||||
a.Tap("连接")
|
||||
a.WaitFor("连接被拒绝,请确认服务器地址与端口")
|
||||
a.Expect("添加服务器")
|
||||
a.Expect("取消")
|
||||
}
|
||||
Reference in new issue
Block a user