From 01bcf54f0cc9310f6ce298b19dda9f38defebec3 Mon Sep 17 00:00:00 2001 From: ayn2op Date: Mon, 23 Jun 2025 22:29:21 -0400 Subject: [PATCH] refactor(cmd): add package comment --- cmd/guilds_tree.go | 1 - cmd/messages_text.go | 17 +++++++---------- cmd/root.go | 1 + 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cmd/guilds_tree.go b/cmd/guilds_tree.go index bc09e0c..1ea8960 100644 --- a/cmd/guilds_tree.go +++ b/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). diff --git a/cmd/messages_text.go b/cmd/messages_text.go index 65fc2f9..86b4ef1 100644 --- a/cmd/messages_text.go +++ b/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() { diff --git a/cmd/root.go b/cmd/root.go index 1d1f009..15e9458 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,3 +1,4 @@ +// Package cmd defines the command-line interface commands package cmd import (