Skip to content

Commit

Permalink
Prepare for mainview
Browse files Browse the repository at this point in the history
  • Loading branch information
mntdent committed Jan 22, 2025
1 parent e5cdd95 commit b7d9a91
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions tui/view-login.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ func (view *LoginView) Error(err string) {

view.parent.App.Redraw()
}
func (view *LoginView) actuallyLogin(ctx context.Context, hs, mxid, password string) {
view.loading = true
view.loginButton.SetText("Logging in...")
err := view.parent.Client.LoginPassword(ctx, hs, mxid, password)
if err == nil {
view.loginButton.SetText("it woked")
} else {
view.Error(err.Error())
}
view.loading = false
view.loginButton.SetText("Login")
}

func (view *LoginView) Login() {
if view.loading {
Expand All @@ -112,13 +124,5 @@ func (view *LoginView) Login() {
mxid := view.id.GetText()
password := view.password.GetText()
ctx := context.TODO()

view.loading = true
view.loginButton.SetText("Logging in...")
err := view.parent.Client.LoginPassword(ctx, hs, mxid, password)
if err == nil {
view.loginButton.SetText("it woked")
} else {
view.Error(err.Error())
}
go view.actuallyLogin(ctx, hs, mxid, password)
}

0 comments on commit b7d9a91

Please sign in to comment.