refactor: inline SetRoot call
This commit is contained in:
parent
427a892ed6
commit
ebd43423eb
1 changed files with 5 additions and 4 deletions
|
|
@ -35,22 +35,23 @@ func newApplication(cfg *config.Config) *application {
|
|||
}
|
||||
|
||||
func (a *application) run(token string) error {
|
||||
var root tview.Primitive
|
||||
if token == "" {
|
||||
root = login.NewForm(a.Application, a.cfg, func(token string) {
|
||||
loginForm := login.NewForm(a.Application, a.cfg, func(token string) {
|
||||
if err := a.run(token); err != nil {
|
||||
slog.Error("failed to run application", "err", err)
|
||||
}
|
||||
})
|
||||
a.SetRoot(loginForm, true)
|
||||
} else {
|
||||
a.chatView = newChatView(a.Application, a.cfg)
|
||||
root = a.chatView
|
||||
if err := openState(token); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a.SetRoot(a.chatView, true)
|
||||
}
|
||||
|
||||
return a.SetRoot(root, true).Run()
|
||||
return a.Run()
|
||||
}
|
||||
|
||||
func (a *application) quit() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue