|
@@ -54,22 +54,29 @@ func (a *application) run(token string) error {
|
|
|
|
|
|
|
|
if token == "" {
|
|
if token == "" {
|
|
|
loginForm := 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)
|
|
|
|
|
|
|
+ if err := a.showChatView(token); err != nil {
|
|
|
|
|
+ slog.Error("failed to show chat view", "err", err)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
a.SetRoot(loginForm)
|
|
a.SetRoot(loginForm)
|
|
|
} else {
|
|
} else {
|
|
|
- a.chatView = newChatView(a.Application, a.cfg)
|
|
|
|
|
- if err := openState(token); err != nil {
|
|
|
|
|
|
|
+ if err := a.showChatView(token); err != nil {
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
- a.SetRoot(a.chatView)
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return a.Run()
|
|
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() {
|
|
func (a *application) quit() {
|
|
|
if discordState != nil {
|
|
if discordState != nil {
|
|
|
if err := discordState.Close(); err != nil {
|
|
if err := discordState.Close(); err != nil {
|