refactor(ui/chat): handle guild tree selection via TreeViewSelectedEvent

This commit is contained in:
ayn2op 2026-03-14 21:09:33 -04:00
parent 8b99036acf
commit 74d485c96d
3 changed files with 6 additions and 4 deletions

2
go.mod
View file

@ -11,7 +11,7 @@ require (
github.com/alecthomas/chroma/v2 v2.23.1
github.com/andybalholm/brotli v1.2.0
github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97
github.com/ayn2op/tview v0.0.0-20260314084311-e6fda4e5838b
github.com/ayn2op/tview v0.0.0-20260315010736-d2153f13054e
github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb
github.com/diamondburned/arikawa/v3 v3.6.1-0.20260311205148-176ad9b9440f
github.com/diamondburned/ningen/v3 v3.0.1-0.20260306213430-5a08d3a709b4

4
go.sum
View file

@ -16,8 +16,8 @@ github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwTo
github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97 h1:WujETUV+v0DEJyZgjeLzQvihWyL80c0Tg4qf0dDo+Io=
github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97/go.mod h1:3kFnpNCa3dF6WryzOMCDao7PfZ7DTCh+pievlfuwV80=
github.com/ayn2op/tview v0.0.0-20260314084311-e6fda4e5838b h1:ZGDcIf5Vrk+/Tl3GMaxuXNQek8oT/FW27nn5xdkXx5A=
github.com/ayn2op/tview v0.0.0-20260314084311-e6fda4e5838b/go.mod h1:lZ8RdOegQWBQafTOasGE7Ps1/Ymy4jmXoPt5vz2QsS0=
github.com/ayn2op/tview v0.0.0-20260315010736-d2153f13054e h1:BRXzZGLUR+zTZ2Dg4/FF1vMNTsZ+6ftmazbUFUIwgJ8=
github.com/ayn2op/tview v0.0.0-20260315010736-d2153f13054e/go.mod h1:lZ8RdOegQWBQafTOasGE7Ps1/Ymy4jmXoPt5vz2QsS0=
github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ=
github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

View file

@ -55,7 +55,6 @@ func newGuildsTree(cfg *config.Config, chatView *Model) *guildsTree {
}).
SetGraphics(cfg.Theme.GuildsTree.Graphics).
SetGraphicsColor(tcell.GetColor(cfg.Theme.GuildsTree.GraphicsColor)).
SetSelectedFunc(gt.onSelected).
SetTitle("Guilds")
return gt
@ -396,6 +395,9 @@ func (gt *guildsTree) collapseParentNode(node *tview.TreeNode) {
func (gt *guildsTree) HandleEvent(event tcell.Event) tview.Command {
switch event := event.(type) {
case *tview.TreeViewSelectedEvent:
gt.onSelected(event.Node)
return nil
case *tview.KeyEvent:
handler := gt.TreeView.HandleEvent