aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/account.go61
-rw-r--r--widgets/dirlist.go4
-rw-r--r--widgets/dirtree.go1
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)
}