aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/account.go1
-rw-r--r--widgets/dirlist.go56
2 files changed, 31 insertions, 26 deletions
diff --git a/widgets/account.go b/widgets/account.go
index d4a74ce8..47bc9924 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -277,6 +277,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
log.Infof("[%s] disconnected.", acct.acct.Name)
acct.SetStatus(state.SetConnected(false))
case *types.OpenDirectory:
+ acct.dirlist.Update(msg)
if store, ok := acct.dirlist.SelectedMsgStore(); ok {
// If we've opened this dir before, we can re-render it from
// memory while we wait for the update and the UI feels
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index b58a9a5c..e9cec458 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -108,6 +108,28 @@ func (dirlist *DirectoryList) Update(msg types.WorkerMessage) {
switch msg := msg.(type) {
case *types.Done:
switch msg := msg.InResponseTo().(type) {
+ case *types.OpenDirectory:
+ dirlist.selected = msg.Directory
+ dirlist.filterDirsByFoldersConfig()
+ hasSelected := false
+ for _, d := range dirlist.dirs {
+ if d == dirlist.selected {
+ hasSelected = true
+ break
+ }
+ }
+ if !hasSelected && dirlist.selected != "" {
+ dirlist.dirs = append(dirlist.dirs, dirlist.selected)
+ }
+ if dirlist.acctConf.EnableFoldersSort {
+ sort.Strings(dirlist.dirs)
+ }
+ dirlist.sortDirsByFoldersSortConfig()
+ store, ok := dirlist.SelectedMsgStore()
+ if !ok {
+ return
+ }
+ store.SetContext(msg.Context)
case *types.ListDirectories:
dirlist.filterDirsByFoldersConfig()
dirlist.sortDirsByFoldersSortConfig()
@@ -162,39 +184,21 @@ func (dirlist *DirectoryList) Select(name string) {
select {
case <-time.After(delay):
dirlist.worker.PostAction(&types.OpenDirectory{
- Context: dirlist.ctx,
+ Context: ctx,
Directory: name,
},
func(msg types.WorkerMessage) {
- switch msg.(type) {
+ switch msg := msg.(type) {
case *types.Error:
dirlist.selecting = ""
- case *types.Done:
- dirlist.selected = dirlist.selecting
- dirlist.filterDirsByFoldersConfig()
- hasSelected := false
- for _, d := range dirlist.dirs {
- if d == dirlist.selected {
- hasSelected = true
- break
- }
- }
- if !hasSelected && dirlist.selected != "" {
- dirlist.dirs = append(dirlist.dirs, dirlist.selected)
- }
- if dirlist.acctConf.EnableFoldersSort {
- sort.Strings(dirlist.dirs)
- }
- dirlist.sortDirsByFoldersSortConfig()
- store, ok := dirlist.SelectedMsgStore()
- if !ok {
- return
- }
- store.SetContext(dirlist.ctx)
+ log.Errorf("(%s) couldn't open directory %s: %v",
+ dirlist.acctConf.Name,
+ name,
+ msg.Error)
+ case *types.Cancelled:
+ log.Debugf("OpenDirectory cancelled")
}
- dirlist.Invalidate()
})
- dirlist.Invalidate()
case <-ctx.Done():
log.Tracef("dirlist: skip %s", name)
return