aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-06-26 10:17:20 +0200
committerRobin Jarry <robin@jarry.cc>2023-06-26 10:53:57 +0200
commitdfabb5232875663884d35f7d69b752f0b56ad64b (patch)
tree2363951318234842e1a0a289b13874c62e3b9bb9 /widgets
parent9cbfb190f65eba73e42b034a39de4b4d35fd404c (diff)
downloadaerc-dfabb5232875663884d35f7d69b752f0b56ad64b.tar.gz
account: remember folder/message when reconnecting
Remember selected folder and message when reconnecting. This is mostly useful for the imap backend when logouts or reconnects happen a lot. Fixes: https://todo.sr.ht/~rjarry/aerc/159 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/account.go8
-rw-r--r--widgets/dirlist.go1
-rw-r--r--widgets/dirtree.go1
3 files changed, 6 insertions, 4 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 0c2ce7d6..e9c86504 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -299,7 +299,8 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
}
case *types.ListDirectories:
acct.dirlist.Update(msg)
- if acct.dirlist.Selected() != "" {
+ if dir := acct.dirlist.Selected(); dir != "" {
+ acct.dirlist.Select(dir)
return
}
// Nothing selected, select based on config
@@ -321,7 +322,10 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
acct.newConn = true
}
case *types.Directory:
- store := acct.newStore(msg.Dir.Name)
+ store, ok := acct.dirlist.MsgStore(msg.Dir.Name)
+ if !ok {
+ store = acct.newStore(msg.Dir.Name)
+ }
acct.dirlist.SetMsgStore(msg.Dir, store)
case *types.DirectoryInfo:
acct.dirlist.Update(msg)
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 788e197f..7d427dcc 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -169,7 +169,6 @@ func (dirlist *DirectoryList) Select(name string) {
switch msg.(type) {
case *types.Error:
dirlist.selecting = ""
- dirlist.selected = ""
case *types.Done:
dirlist.selected = dirlist.selecting
dirlist.filterDirsByFoldersConfig()
diff --git a/widgets/dirtree.go b/widgets/dirtree.go
index 027a8747..035a0a81 100644
--- a/widgets/dirtree.go
+++ b/widgets/dirtree.go
@@ -44,7 +44,6 @@ func (dt *DirectoryTree) OnVirtualNode(cb func()) {
func (dt *DirectoryTree) ClearList() {
dt.list = make([]*types.Thread, 0)
- dt.selected = ""
}
func (dt *DirectoryTree) Update(msg types.WorkerMessage) {