diff options
-rw-r--r-- | widgets/account.go | 5 | ||||
-rw-r--r-- | widgets/dirlist.go | 5 | ||||
-rw-r--r-- | widgets/dirtree.go | 15 |
3 files changed, 25 insertions, 0 deletions
diff --git a/widgets/account.go b/widgets/account.go index a99f7a48..e28804de 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -95,6 +95,11 @@ func NewAccountView( view.msglist = NewMessageList(aerc, view) view.grid.AddChild(view.msglist).At(0, 1) + view.dirlist.OnVirtualNode(func() { + view.msglist.SetStore(nil) + view.Invalidate() + }) + go func() { defer log.PanicHandler() diff --git a/widgets/dirlist.go b/widgets/dirlist.go index 6a10c99a..25d1e7ff 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -31,6 +31,8 @@ type DirectoryLister interface { List() []string ClearList() + OnVirtualNode(func()) + NextPrev(int) CollapseFolder() @@ -99,6 +101,9 @@ func (dirlist *DirectoryList) ClearList() { dirlist.dirs = []string{} } +func (dirlist *DirectoryList) OnVirtualNode(_ func()) { +} + func (dirlist *DirectoryList) Update(msg types.WorkerMessage) { switch msg := msg.(type) { case *types.Done: diff --git a/widgets/dirtree.go b/widgets/dirtree.go index c11a1fd0..98b25850 100644 --- a/widgets/dirtree.go +++ b/widgets/dirtree.go @@ -23,6 +23,9 @@ type DirectoryTree struct { list []*types.Thread treeDirs []string + + virtual bool + virtualCb func() } func NewDirectoryTree(dirlist *DirectoryList) DirectoryLister { @@ -30,10 +33,15 @@ func NewDirectoryTree(dirlist *DirectoryList) DirectoryLister { DirectoryList: dirlist, listIdx: -1, list: make([]*types.Thread, 0), + virtualCb: func() {}, } return dt } +func (dt *DirectoryTree) OnVirtualNode(cb func()) { + dt.virtualCb = cb +} + func (dt *DirectoryTree) ClearList() { dt.list = make([]*types.Thread, 0) dt.selected = "" @@ -168,6 +176,9 @@ func (dt *DirectoryTree) Clicked(x int, y int) (string, bool) { } func (dt *DirectoryTree) SelectedMsgStore() (*lib.MessageStore, bool) { + if dt.virtual { + return nil, false + } if findString(dt.treeDirs, dt.selected) < 0 { dt.buildTree() if idx := findString(dt.treeDirs, dt.selected); idx >= 0 { @@ -229,7 +240,11 @@ func (dt *DirectoryTree) NextPrev(delta int) { dt.listIdx = newIdx if path := dt.getDirectory(dt.list[dt.listIdx]); path != "" { + dt.virtual = false dt.Select(path) + } else { + dt.virtual = true + dt.virtualCb() } } |