From 2610c2bf9f220e188e4cf8f4b9bcf88bde541958 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 18 Feb 2020 21:31:28 +0200 Subject: Update readme a bit and add SSO support --- ui/view-login.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'ui') diff --git a/ui/view-login.go b/ui/view-login.go index a65a77c..023aaad 100644 --- a/ui/view-login.go +++ b/ui/view-login.go @@ -44,6 +44,8 @@ type LoginView struct { loginButton *mauview.Button quitButton *mauview.Button + loading bool + matrix ifc.MatrixContainer config *config.Config parent *GomuksUI @@ -112,11 +114,7 @@ func (view *LoginView) Error(err string) { view.parent.Render() } -func (view *LoginView) Login() { - hs := view.homeserver.GetText() - mxid := view.username.GetText() - password := view.password.GetText() - +func (view *LoginView) actuallyLogin(hs, mxid, password string) { debug.Printf("Logging into %s as %s...", hs, mxid) view.config.HS = hs err := view.matrix.InitClient() @@ -130,8 +128,23 @@ func (view *LoginView) Login() { view.Error(httpErr.Message) } } else { - view.Error("Failed to connect to server.") + view.Error(err.Error()) } debug.Print("Login error:", err) } + view.loading = false + view.loginButton.SetText("Login") +} + +func (view *LoginView) Login() { + if view.loading { + return + } + hs := view.homeserver.GetText() + mxid := view.username.GetText() + password := view.password.GetText() + + view.loading = true + view.loginButton.SetText("Logging in...") + go view.actuallyLogin(hs, mxid, password) } -- cgit v1.2.3