mirror of
https://github.com/diamondburned/cchat-gtk.git
synced 2024-12-23 04:36:49 +00:00
save/restore closed server paths
This commit is contained in:
parent
89c2fd3456
commit
c0a7fe3750
|
@ -91,10 +91,13 @@ func Save() {
|
|||
}
|
||||
|
||||
func Update(b traverse.Breadcrumber, expanded bool) {
|
||||
if expanded {
|
||||
var path = traverse.TryID(b)
|
||||
var node = paths
|
||||
|
||||
// TODO: this doesn't actually account for paths that no longer exist, but
|
||||
// it's complex to check.
|
||||
|
||||
if expanded {
|
||||
// Descend and initialize.
|
||||
for i := 0; i < len(path); i++ {
|
||||
ch, ok := node[path[i]]
|
||||
|
@ -106,7 +109,20 @@ func Update(b traverse.Breadcrumber, expanded bool) {
|
|||
node = ch
|
||||
}
|
||||
} else {
|
||||
for i := 0; i < len(path); i++ {
|
||||
ch, ok := node[path[i]]
|
||||
if !ok {
|
||||
// We can't find anything.
|
||||
return
|
||||
}
|
||||
|
||||
if i == len(path)-1 {
|
||||
// We're at the last node, so we can delete things now.
|
||||
delete(node, path[i])
|
||||
}
|
||||
|
||||
node = ch
|
||||
}
|
||||
}
|
||||
|
||||
Save()
|
||||
|
|
|
@ -392,6 +392,9 @@ func (r *ServerRow) SetRevealChild(reveal bool) {
|
|||
// Actually reveal the children.
|
||||
r.childrev.SetRevealChild(reveal)
|
||||
|
||||
// Save the path.
|
||||
savepath.Update(r, reveal)
|
||||
|
||||
// If this isn't a reveal, then we don't need to load.
|
||||
if !reveal {
|
||||
return
|
||||
|
@ -401,9 +404,6 @@ func (r *ServerRow) SetRevealChild(reveal bool) {
|
|||
// to call Servers on this. Now, we already know that there are hollow
|
||||
// servers in the children container.
|
||||
r.children.LoadAll()
|
||||
|
||||
// Save the path.
|
||||
savepath.Update(r, reveal)
|
||||
}
|
||||
|
||||
// GetRevealChild returns whether or not the server list is expanded, or always
|
||||
|
|
Loading…
Reference in a new issue