refactor(chat): adapt to tree view changes
This commit is contained in:
parent
89513df829
commit
8a64c33ce5
3 changed files with 11 additions and 24 deletions
2
go.mod
2
go.mod
|
|
@ -10,7 +10,7 @@ require (
|
|||
github.com/andybalholm/brotli v1.2.2
|
||||
github.com/ayn2op/arikawa/v3 v3.0.0-20260708075022-9cc760fe507e
|
||||
github.com/ayn2op/ningen/v3 v3.0.1-0.20260708075321-0ba1ffc70bd6
|
||||
github.com/ayn2op/tview v0.0.0-20260806205637-7fdbc79aff89
|
||||
github.com/ayn2op/tview v0.0.0-20260807061323-573f4b04d4a8
|
||||
github.com/bogdanfinn/fhttp v0.6.8
|
||||
github.com/bogdanfinn/tls-client v1.15.1
|
||||
github.com/gdamore/tcell/v3 v3.4.1
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -14,8 +14,8 @@ github.com/ayn2op/arikawa/v3 v3.0.0-20260708075022-9cc760fe507e h1:rsMifRXwxkbha
|
|||
github.com/ayn2op/arikawa/v3 v3.0.0-20260708075022-9cc760fe507e/go.mod h1:gqklpHK7WHYTzpd1ZY6Ho/p9GURBghzBCzRiBYpaUP8=
|
||||
github.com/ayn2op/ningen/v3 v3.0.1-0.20260708075321-0ba1ffc70bd6 h1:/khHm6G+GWwXpmwA8bJoaXoUhubqMEUG6spjZsnklIw=
|
||||
github.com/ayn2op/ningen/v3 v3.0.1-0.20260708075321-0ba1ffc70bd6/go.mod h1:vqLIvETLkjc2vIgQzVEBqpGNCrgNe7YJqS9TUAJsXRI=
|
||||
github.com/ayn2op/tview v0.0.0-20260806205637-7fdbc79aff89 h1:/cvaZ7JUGRuclbqkWsH435iuW5DmiGOr/hV8sJ8SSHI=
|
||||
github.com/ayn2op/tview v0.0.0-20260806205637-7fdbc79aff89/go.mod h1:bJZdl/FfspPLEW3nuX6ubt7YbmDoSj7f2IoWH37w1NE=
|
||||
github.com/ayn2op/tview v0.0.0-20260807061323-573f4b04d4a8 h1:IZVthAp7XM3Z3EZX6mjtgbJUMVzJiYpJcU+5PN9k1J4=
|
||||
github.com/ayn2op/tview v0.0.0-20260807061323-573f4b04d4a8/go.mod h1:bJZdl/FfspPLEW3nuX6ubt7YbmDoSj7f2IoWH37w1NE=
|
||||
github.com/bdandy/go-errors v1.2.2 h1:WdFv/oukjTJCLa79UfkGmwX7ZxONAihKu4V0mLIs11Q=
|
||||
github.com/bdandy/go-errors v1.2.2/go.mod h1:NkYHl4Fey9oRRdbB1CoC6e84tuqQHiqrOcZpqFEkBxM=
|
||||
github.com/bdandy/go-socks4 v1.2.3 h1:Q6Y2heY1GRjCtHbmlKfnwrKVU/k81LS8mRGLRlmDlic=
|
||||
|
|
|
|||
|
|
@ -326,17 +326,13 @@ func (gt *guildsTree) loadChannel(channel discord.Channel) tview.Cmd {
|
|||
}
|
||||
|
||||
func (gt *guildsTree) collapseParentNode(node *tree.Node) {
|
||||
gt.
|
||||
Root().
|
||||
Walk(func(n, parent *tree.Node) bool {
|
||||
if n == node && parent.GetLevel() != 0 {
|
||||
path := gt.GetPath(node)
|
||||
if len(path) < 3 {
|
||||
return
|
||||
}
|
||||
parent := path[len(path)-2]
|
||||
parent.Collapse()
|
||||
gt.SetCurrentNode(parent)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func (gt *guildsTree) Update(msg tview.Msg) tview.Cmd {
|
||||
|
|
@ -490,16 +486,7 @@ func (gt *guildsTree) collapseKeybinds() []keybind.Keybind {
|
|||
}
|
||||
|
||||
func (gt *guildsTree) canCollapseParent(node *tree.Node) bool {
|
||||
if node == nil {
|
||||
return false
|
||||
}
|
||||
path := gt.GetPath(node)
|
||||
// Path layout is [root, ..., node]. A non-root parent means at least 3 nodes.
|
||||
if len(path) < 3 {
|
||||
return false
|
||||
}
|
||||
parent := path[len(path)-2]
|
||||
return parent != nil && parent.GetLevel() != 0
|
||||
return node != nil && len(gt.GetPath(node)) >= 3
|
||||
}
|
||||
|
||||
func (gt *guildsTree) canCollapseAll() bool {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue