Просмотр исходного кода

refactor(cmd): fix common lint issues

ayn2op 10 месяцев назад
Родитель
Сommit
a72f606833
2 измененных файлов с 15 добавлено и 16 удалено
  1. 12 10
      cmd/application.go
  2. 3 6
      cmd/state.go

+ 12 - 10
cmd/application.go

@@ -40,9 +40,10 @@ func newApplication(cfg *config.Config) *application {
 		messageInput: newMessageInput(cfg),
 	}
 
-	app.EnableMouse(cfg.Mouse)
-	app.SetInputCapture(app.onInputCapture)
 	app.flex.SetInputCapture(app.onFlexInputCapture)
+	app.
+		EnableMouse(cfg.Mouse).
+		SetInputCapture(app.onInputCapture)
 	return app
 }
 
@@ -50,20 +51,19 @@ func (a *application) run(token string) error {
 	if token == "" {
 		loginForm := login.NewForm(a.cfg, func(token string) {
 			if err := a.run(token); err != nil {
-				slog.Error("failed to show app", "err", err)
-				return
+				slog.Error("failed to run application", "err", err)
 			}
 		})
 
 		return a.SetRoot(loginForm, true).Run()
-	} else {
-		if err := openState(token); err != nil {
-			return err
-		}
+	}
 
-		a.init()
-		return a.SetRoot(a.pages, true).Run()
+	if err := openState(token); err != nil {
+		return err
 	}
+
+	a.init()
+	return a.SetRoot(a.pages, true).Run()
 }
 
 func (a *application) quit() {
@@ -84,10 +84,12 @@ func (a *application) init() {
 		SetDirection(tview.FlexRow).
 		AddItem(a.messagesText, 0, 1, false).
 		AddItem(a.messageInput, 3, 1, false)
+
 	// The guilds tree is always focused first at start-up.
 	a.flex.
 		AddItem(a.guildsTree, 0, 1, true).
 		AddItem(right, 0, 4, false)
+
 	a.pages.AddAndSwitchToPage(flexPageName, a.flex, true)
 }
 

+ 3 - 6
cmd/state.go

@@ -48,12 +48,9 @@ func openState(token string) error {
 	discordState.AddHandler(func(event *ws.RawEvent) {
 		slog.Debug(
 			"new raw event",
-			"code",
-			event.OriginalCode,
-			"type",
-			event.OriginalType,
-			"data",
-			event.Raw,
+			"code", event.OriginalCode,
+			"type", event.OriginalType,
+			"data", event.Raw,
 		)
 	})