fix(cmd/application): prevent duplicate application Run() calls
Closes #679
This commit is contained in:
parent
92eb4425a1
commit
552250a355
1 changed files with 12 additions and 5 deletions
|
|
@ -54,22 +54,29 @@ func (a *application) run(token string) error {
|
|||
|
||||
if token == "" {
|
||||
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)
|
||||
if err := a.showChatView(token); err != nil {
|
||||
slog.Error("failed to show chat view", "err", err)
|
||||
}
|
||||
})
|
||||
a.SetRoot(loginForm)
|
||||
} else {
|
||||
a.chatView = newChatView(a.Application, a.cfg)
|
||||
if err := openState(token); err != nil {
|
||||
if err := a.showChatView(token); err != nil {
|
||||
return err
|
||||
}
|
||||
a.SetRoot(a.chatView)
|
||||
}
|
||||
|
||||
return a.Run()
|
||||
}
|
||||
|
||||
func (a *application) showChatView(token string) error {
|
||||
a.chatView = newChatView(a.Application, a.cfg)
|
||||
if err := openState(token); err != nil {
|
||||
return err
|
||||
}
|
||||
a.SetRoot(a.chatView)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *application) quit() {
|
||||
if discordState != nil {
|
||||
if err := discordState.Close(); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue