diff --git a/go.mod b/go.mod index 2c237b9..ce6d2cc 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,8 @@ require ( github.com/BurntSushi/toml v1.6.0 github.com/alecthomas/chroma/v2 v2.27.0 github.com/andybalholm/brotli v1.2.2 - github.com/ayn2op/arikawa/v3 v3.0.0-20260818065153-b362b4f1c64f - github.com/ayn2op/ningen/v3 v3.0.1-0.20260818060652-dd6af4f3af5e + github.com/ayn2op/arikawa/v3 v3.0.0-20260818073432-f49cfbdeaecd + github.com/ayn2op/ningen/v3 v3.0.1-0.20260818073850-83e35312c6cc github.com/ayn2op/tview v0.0.0-20260812042550-0532d50b709f github.com/bogdanfinn/fhttp v0.6.8 github.com/bogdanfinn/tls-client v1.15.1 diff --git a/go.sum b/go.sum index c0e3ab4..8280b4e 100644 --- a/go.sum +++ b/go.sum @@ -10,10 +10,10 @@ github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/andybalholm/brotli v1.2.2 h1:HzTuoo2ErYQqf5qvcJInB8uvqSVxRttzkFexPWtnceM= github.com/andybalholm/brotli v1.2.2/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= -github.com/ayn2op/arikawa/v3 v3.0.0-20260818065153-b362b4f1c64f h1:BZOR5rhBgQq7mNqdlcn2ubBk723KK85y8FSNECQAtO8= -github.com/ayn2op/arikawa/v3 v3.0.0-20260818065153-b362b4f1c64f/go.mod h1:O0QAm4VBLKBF01sofDEsAHGfD8+Tk8iWNYWksojTt6A= -github.com/ayn2op/ningen/v3 v3.0.1-0.20260818060652-dd6af4f3af5e h1:Ulb1o3SluOJOp7iUztOX+ZUlMprCLMSe1dS4D5H+VkM= -github.com/ayn2op/ningen/v3 v3.0.1-0.20260818060652-dd6af4f3af5e/go.mod h1:pTZpPeql1+s/RPziaJKw1aXBtzjz3/CeshRuWkXyv3k= +github.com/ayn2op/arikawa/v3 v3.0.0-20260818073432-f49cfbdeaecd h1:uXVZPx8arfvYQAHSfgjBo6zy2Yrn2eFi+VTRgPQQ/qA= +github.com/ayn2op/arikawa/v3 v3.0.0-20260818073432-f49cfbdeaecd/go.mod h1:O0QAm4VBLKBF01sofDEsAHGfD8+Tk8iWNYWksojTt6A= +github.com/ayn2op/ningen/v3 v3.0.1-0.20260818073850-83e35312c6cc h1:B5QnZxF5Ukm1nzdUzQlcL8H/1WUV7moAGdg5xi95ULA= +github.com/ayn2op/ningen/v3 v3.0.1-0.20260818073850-83e35312c6cc/go.mod h1:XhtckMjvipRb0JyG6nDpfoGu0p8jxxrHqjAlwAewejE= github.com/ayn2op/tview v0.0.0-20260812042550-0532d50b709f h1:RidxK97+mKbM25L2iIdM6i6nfdZBSd1chNCu8e0PbxE= github.com/ayn2op/tview v0.0.0-20260812042550-0532d50b709f/go.mod h1:l/sE5dmdvLVlv/2rvoJFcFVl6uq9w2Z62/SfGpJiquw= github.com/bdandy/go-errors v1.2.2 h1:WdFv/oukjTJCLa79UfkGmwX7ZxONAihKu4V0mLIs11Q= diff --git a/internal/keyring/keyring_test.go b/internal/keyring/keyring_test.go index 4b3cff5..d852fe3 100644 --- a/internal/keyring/keyring_test.go +++ b/internal/keyring/keyring_test.go @@ -9,7 +9,7 @@ import ( const testToken = "abc123" -var testErr = errors.New("boom") +var errTest = errors.New("boom") func TestSetToken(t *testing.T) { t.Run("success", func(t *testing.T) { @@ -30,7 +30,7 @@ func TestSetToken(t *testing.T) { }) t.Run("error", func(t *testing.T) { - zkeyring.MockInitWithError(testErr) + zkeyring.MockInitWithError(errTest) if err := SetToken(testToken); err == nil { t.Fatal("expected error") @@ -65,7 +65,7 @@ func TestGetToken(t *testing.T) { }) t.Run("error", func(t *testing.T) { - zkeyring.MockInitWithError(testErr) + zkeyring.MockInitWithError(errTest) if _, err := GetToken(); err == nil { t.Fatal("expected error") @@ -100,7 +100,7 @@ func TestDeleteToken(t *testing.T) { }) t.Run("error", func(t *testing.T) { - zkeyring.MockInitWithError(testErr) + zkeyring.MockInitWithError(errTest) if err := DeleteToken(); err == nil { t.Fatal("expected error") diff --git a/internal/ui/chat/composer.go b/internal/ui/chat/composer.go index 6ee41b4..0037e72 100644 --- a/internal/ui/chat/composer.go +++ b/internal/ui/chat/composer.go @@ -328,7 +328,7 @@ func (c *composer) send() tview.Cmd { return func() tview.Msg { defer closeFiles(data.Files)() if edit { - editData := api.EditMessageData{Content: option.NewNullableString(text)} + editData := api.EditMessageData{Content: option.SomeNullable(text)} if _, err := c.chat.state.EditMessageComplex(editMessage.ChannelID, editMessage.ID, editData); err != nil { slog.Error("failed to edit message", "err", err) } @@ -490,7 +490,8 @@ func (c *composer) tabSuggest() tview.Cmd { } // DMs have recipients, not members - if !gID.IsValid() { + switch { + case !gID.IsValid(): if name == "" { // show recent messages' authors msgs, err := c.chat.state.Cabinet.Messages(cID) if err != nil { @@ -512,7 +513,7 @@ func (c *composer) tabSuggest() tview.Cmd { c.addMentionUser(&users[r.Index]) } } - } else if name == "" { // show recent messages' authors + case name == "": // show recent messages' authors msgs, err := c.chat.state.Cabinet.Messages(cID) if err != nil { return nil @@ -529,7 +530,7 @@ func (c *composer) tabSuggest() tview.Cmd { } } } - } else { + default: searchCmd := c.searchMember(gID, name) mems, err := c.chat.state.Cabinet.Members(gID) if err != nil { @@ -621,7 +622,7 @@ func (c *composer) searchMember(gID discord.GuildID, name string) tview.Cmd { return func() tview.Msg { if err := c.chat.state.SendGateway(context.Background(), &gateway.RequestGuildMembersCommand{ GuildIDs: []discord.GuildID{gID}, - Query: option.NewString(name), + Query: option.Some(name), Presences: c.chat.state.MemberState.RequestPresences, Limit: c.chat.state.MemberState.SearchLimit, Nonce: nonce, diff --git a/internal/ui/chat/messages_list.go b/internal/ui/chat/messages_list.go index 524979e..0c91331 100644 --- a/internal/ui/chat/messages_list.go +++ b/internal/ui/chat/messages_list.go @@ -706,7 +706,7 @@ func embedLines(embed discord.Embed, contentURLs map[string]struct{}) []embedLin } appendURL := func(url discord.URL) { - u := strings.TrimSpace(string(url)) + u := strings.TrimSpace(url) if u == "" { return } @@ -723,7 +723,7 @@ func embedLines(embed discord.Embed, contentURLs map[string]struct{}) []embedLin if embed.Author != nil { appendUnique(embed.Author.Name, embedLineAuthor, "") } - appendUnique(embed.Title, embedLineTitle, string(embed.URL)) + appendUnique(embed.Title, embedLineTitle, embed.URL) // Some Discord embeds include markdown-escaped punctuation in raw payload text (e.g. "\."), so normalize for display. appendUnique(unescapeMarkdownEscapes(embed.Description), embedLineDescription, "") @@ -1112,13 +1112,13 @@ func extractEmbedURLs(embeds []discord.Embed) []string { urls := make([]string, 0, len(embeds)*3) for _, embed := range embeds { if embed.URL != "" { - urls = append(urls, string(embed.URL)) + urls = append(urls, embed.URL) } if embed.Image != nil && embed.Image.URL != "" { - urls = append(urls, string(embed.Image.URL)) + urls = append(urls, embed.Image.URL) } if embed.Video != nil && embed.Video.URL != "" { - urls = append(urls, string(embed.Video.URL)) + urls = append(urls, embed.Video.URL) } } return urls @@ -1242,11 +1242,11 @@ func (ml *messagesList) reply(mention bool) tview.Cmd { data := ml.chat.composer.sendMessageData data.Reference = &discord.MessageReference{MessageID: selectedMessage.ID} - data.AllowedMentions = &api.AllowedMentions{RepliedUser: option.False} + data.AllowedMentions = &api.AllowedMentions{RepliedUser: option.Some(false)} title := "Replying to " if mention { - data.AllowedMentions.RepliedUser = option.True + data.AllowedMentions.RepliedUser = option.Some(true) title = "[@] " + title } diff --git a/internal/ui/login/password/model.go b/internal/ui/login/password/model.go index 52da93d..904cdf7 100644 --- a/internal/ui/login/password/model.go +++ b/internal/ui/login/password/model.go @@ -24,8 +24,7 @@ func (m *Model) Label() string { } func (m *Model) Update(msg tview.Msg) tview.Cmd { - switch msg.(type) { - case tview.FormSubmitMsg: + if _, ok := msg.(tview.FormSubmitMsg); ok { login := m.GetFormItem(0).(*tview.InputField).Text() password := m.GetFormItem(1).(*tview.InputField).Text() if login == "" || password == "" { diff --git a/internal/ui/login/token/model.go b/internal/ui/login/token/model.go index 13cc06d..199ea04 100644 --- a/internal/ui/login/token/model.go +++ b/internal/ui/login/token/model.go @@ -23,8 +23,7 @@ func (m *Model) Label() string { } func (m *Model) Update(msg tview.Msg) tview.Cmd { - switch msg.(type) { - case tview.FormSubmitMsg: + if _, ok := msg.(tview.FormSubmitMsg); ok { token := m.GetFormItem(0).(*tview.InputField).Text() if token == "" { return nil