fix(cmd/application): prevent duplicate application Run() calls

Closes #679
This commit is contained in:
ayn2op 2025-12-30 18:08:25 -05:00
parent 92eb4425a1
commit 552250a355

View file

@ -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 {