Przeglądaj źródła

refactor(cmd): add package comment

ayn2op 10 miesięcy temu
rodzic
commit
01bcf54f0c
3 zmienionych plików z 8 dodań i 11 usunięć
  1. 0 1
      cmd/guilds_tree.go
  2. 7 10
      cmd/messages_text.go
  3. 1 0
      cmd/root.go

+ 0 - 1
cmd/guilds_tree.go

@@ -29,7 +29,6 @@ func newGuildsTree(cfg *config.Config) *guildsTree {
 	}
 
 	gt.Box = ui.ConfigureBox(gt.Box, &cfg.Theme)
-
 	gt.
 		SetRoot(tview.NewTreeNode("")).
 		SetTopLevel(1).

+ 7 - 10
cmd/messages_text.go

@@ -416,7 +416,7 @@ func (mt *messagesText) open() {
 			go openURL(msg.Attachments[0].URL)
 		}
 	} else {
-		mt.showUrlSelector(urls, msg.Attachments)
+		mt.showAttachmentsList(urls, msg.Attachments)
 	}
 }
 
@@ -443,19 +443,15 @@ func extractURLs(content string) []string {
 	return urls
 }
 
-func (mt *messagesText) showUrlSelector(urls []string, attachments []discord.Attachment) {
-	done := func() {
-		app.pages.RemovePage(attachmentsListPageName).SwitchToPage(flexPageName)
-		app.SetFocus(mt)
-	}
-
+func (mt *messagesText) showAttachmentsList(urls []string, attachments []discord.Attachment) {
 	list := tview.NewList().
 		SetWrapAround(true).
 		SetHighlightFullLine(true).
 		ShowSecondaryText(false).
-		SetDoneFunc(done)
-	list.Box = ui.ConfigureBox(list.Box, &mt.cfg.Theme)
-
+		SetDoneFunc(func() {
+			app.pages.RemovePage(attachmentsListPageName).SwitchToPage(flexPageName)
+			app.SetFocus(mt)
+		})
 	list.
 		SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
 			switch event.Name() {
@@ -471,6 +467,7 @@ func (mt *messagesText) showUrlSelector(urls []string, attachments []discord.Att
 
 			return event
 		})
+	list.Box = ui.ConfigureBox(list.Box, &mt.cfg.Theme)
 
 	for i, a := range attachments {
 		list.AddItem(a.Filename, "", rune('a'+i), func() {

+ 1 - 0
cmd/root.go

@@ -1,3 +1,4 @@
+// Package cmd defines the command-line interface commands
 package cmd
 
 import (