diff options
author | Koni Marti <koni.marti@gmail.com> | 2023-06-05 20:41:48 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-06-17 23:19:07 +0200 |
commit | b13c45797a1ea2d27f162c0fde0b640d7b24471e (patch) | |
tree | c7aac869d156703add6bb2379546dff0664d1b8a /widgets | |
parent | 04bcfd5cf5aacd60ea70ac773aa6021c4f9c471a (diff) | |
download | aerc-b13c45797a1ea2d27f162c0fde0b640d7b24471e.tar.gz |
account: create new store when creating folders
Add a correct message store entry to the DirStore for newly created
directories. This is currently not done, so the directory name does
either not show up in the directory list or contains a nil message
store. Either way, such a directory cannot be used in the current
session and aerc needs to be restarted/reconnected. This affects the
:mkdir and :archive commands (archive when a new directory is created).
To reproduce on imap: create a new directory (:mkdir testdir), try to
move a message into it (:move testdir). It will not show up because
there is not message store.
Fixes: 8ced001d ("listDirectories: refactor listdirectories handling")
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/account.go | 61 | ||||
-rw-r--r-- | widgets/dirlist.go | 4 | ||||
-rw-r--r-- | widgets/dirtree.go | 1 |
3 files changed, 40 insertions, 26 deletions
diff --git a/widgets/account.go b/widgets/account.go index d76333d2..0c2ce7d6 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -229,11 +229,40 @@ func (acct *AccountView) isSelected() bool { return acct == acct.aerc.SelectedAccount() } +func (acct *AccountView) newStore(name string) *lib.MessageStore { + uiConf := acct.dirlist.UiConfig(name) + store := lib.NewMessageStore(acct.worker, + acct.GetSortCriteria(), + uiConf.ThreadingEnabled, + uiConf.ForceClientThreads, + uiConf.ClientThreadsDelay, + uiConf.ReverseOrder, + uiConf.ReverseThreadOrder, + uiConf.SortThreadSiblings, + func(msg *models.MessageInfo) { + err := hooks.RunHook(&hooks.MailReceived{ + MsgInfo: msg, + }) + if err != nil { + msg := fmt.Sprintf("mail-received hook: %s", err) + acct.aerc.PushError(msg) + } + }, func() { + if uiConf.NewMessageBell { + acct.host.Beep() + } + }, + acct.updateSplitView, + ) + store.SetMarker(marker.New(store)) + return store +} + func (acct *AccountView) onMessage(msg types.WorkerMessage) { msg = acct.worker.ProcessMessage(msg) switch msg := msg.(type) { case *types.Done: - switch msg.InResponseTo().(type) { + switch resp := msg.InResponseTo().(type) { case *types.Connect, *types.Reconnect: acct.SetStatus(state.ConnectionActivity("Listing mailboxes...")) log.Infof("[%s] connected.", acct.acct.Name) @@ -257,6 +286,10 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) { acct.msglist.SetStore(nil) } case *types.CreateDirectory: + store := acct.newStore(resp.Directory) + acct.dirlist.SetMsgStore(&models.Directory{ + Name: resp.Directory, + }, store) acct.dirlist.Update(msg) case *types.RemoveDirectory: acct.dirlist.Update(msg) @@ -288,31 +321,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) { acct.newConn = true } case *types.Directory: - name := msg.Dir.Name - store := lib.NewMessageStore(acct.worker, - acct.GetSortCriteria(), - acct.dirlist.UiConfig(name).ThreadingEnabled, - acct.dirlist.UiConfig(name).ForceClientThreads, - acct.dirlist.UiConfig(name).ClientThreadsDelay, - acct.dirlist.UiConfig(name).ReverseOrder, - acct.dirlist.UiConfig(name).ReverseThreadOrder, - acct.dirlist.UiConfig(name).SortThreadSiblings, - func(msg *models.MessageInfo) { - err := hooks.RunHook(&hooks.MailReceived{ - MsgInfo: msg, - }) - if err != nil { - msg := fmt.Sprintf("mail-received hook: %s", err) - acct.aerc.PushError(msg) - } - }, func() { - if acct.dirlist.UiConfig(name).NewMessageBell { - acct.host.Beep() - } - }, - acct.updateSplitView, - ) - store.SetMarker(marker.New(store)) + 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 8112ebd2..a1d4eddb 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -117,6 +117,10 @@ func (dirlist *DirectoryList) Update(msg types.WorkerMessage) { dirlist.store.Remove(msg.Directory) dirlist.filterDirsByFoldersConfig() dirlist.sortDirsByFoldersSortConfig() + case *types.CreateDirectory: + dirlist.filterDirsByFoldersConfig() + dirlist.sortDirsByFoldersSortConfig() + dirlist.Invalidate() } case *types.DirectoryInfo: dir := dirlist.Directory(msg.Info.Name) diff --git a/widgets/dirtree.go b/widgets/dirtree.go index 9a33e6c3..027a8747 100644 --- a/widgets/dirtree.go +++ b/widgets/dirtree.go @@ -55,6 +55,7 @@ func (dt *DirectoryTree) Update(msg types.WorkerMessage) { case *types.RemoveDirectory, *types.ListDirectories, *types.CreateDirectory: dt.DirectoryList.Update(msg) dt.buildTree() + dt.Invalidate() default: dt.DirectoryList.Update(msg) } |