diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-08-12 14:51:25 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-08-22 09:30:37 +0200 |
commit | e1b62db583c39ae67cd6aa02b0ebde642eda308c (patch) | |
tree | 9fc9ffcf4f9d6be7f23175466fc6b2c423562d56 /widgets | |
parent | 0db924dc14a38109d892613bb4e16159ff305350 (diff) | |
download | aerc-e1b62db583c39ae67cd6aa02b0ebde642eda308c.tar.gz |
fix: Set proper UIConfig for msgstores
The merged UIConfig used to create new message stores is based on the
selected directory. If the message store is created by other means than
selecting (ListDirectories for maildir/notmuch/mbox, or check-mail) it
may have an incorrect configuration if the user has folder-specific
values for:
- Threaded view
- Client built threads
- Client threads delay
- Sort criteria
- NewMessage bell
Use the correct merged UIConfig when creating a new message store.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/account.go | 11 | ||||
-rw-r--r-- | widgets/dirlist.go | 29 | ||||
-rw-r--r-- | widgets/dirtree.go | 10 | ||||
-rw-r--r-- | widgets/msglist.go | 2 |
4 files changed, 28 insertions, 24 deletions
diff --git a/widgets/account.go b/widgets/account.go index b92a619d..bc2dc360 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -42,7 +42,7 @@ type AccountView struct { func (acct *AccountView) UiConfig() *config.UIConfig { if dirlist := acct.Directories(); dirlist != nil { - return dirlist.UiConfig() + return dirlist.UiConfig("") } return acct.uiConf } @@ -291,16 +291,17 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) { if store, ok := acct.dirlist.MsgStore(msg.Info.Name); ok { store.Update(msg) } else { + name := msg.Info.Name store = lib.NewMessageStore(acct.worker, msg.Info, acct.GetSortCriteria(), - acct.UiConfig().ThreadingEnabled, - acct.UiConfig().ForceClientThreads, - acct.UiConfig().ClientThreadsDelay, + acct.dirlist.UiConfig(name).ThreadingEnabled, + acct.dirlist.UiConfig(name).ForceClientThreads, + acct.dirlist.UiConfig(name).ClientThreadsDelay, func(msg *models.MessageInfo) { acct.conf.Triggers.ExecNewEmail(acct.acct, acct.conf, msg) }, func() { - if acct.UiConfig().NewMessageBell { + if acct.dirlist.UiConfig(name).NewMessageBell { acct.host.Beep() } }) diff --git a/widgets/dirlist.go b/widgets/dirlist.go index 03f9239a..38f3c840 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -43,7 +43,7 @@ type DirectoryLister interface { FilterDirs([]string, []string, bool) []string - UiConfig() *config.UIConfig + UiConfig(string) *config.UIConfig } type DirectoryList struct { @@ -78,7 +78,7 @@ func NewDirectoryList(conf *config.AercConfig, acctConf *config.AccountConfig, skipSelectCancel: cancel, uiConf: uiConfMap, } - uiConf := dirlist.UiConfig() + uiConf := dirlist.UiConfig("") dirlist.spinner = NewSpinner(uiConf) dirlist.spinner.OnInvalidate(func(_ ui.Drawable) { dirlist.Invalidate() @@ -92,15 +92,18 @@ func NewDirectoryList(conf *config.AercConfig, acctConf *config.AccountConfig, return dirlist } -func (dirlist *DirectoryList) UiConfig() *config.UIConfig { - if ui, ok := dirlist.uiConf[dirlist.Selected()]; ok { +func (dirlist *DirectoryList) UiConfig(dir string) *config.UIConfig { + if dir == "" { + dir = dirlist.Selected() + } + if ui, ok := dirlist.uiConf[dir]; ok { return ui } ui := dirlist.aercConf.GetUiConfig(map[config.ContextType]string{ config.UI_CONTEXT_ACCOUNT: dirlist.acctConf.Name, - config.UI_CONTEXT_FOLDER: dirlist.Selected(), + config.UI_CONTEXT_FOLDER: dir, }) - dirlist.uiConf[dirlist.Selected()] = ui + dirlist.uiConf[dir] = ui return ui } @@ -154,7 +157,7 @@ func (dirlist *DirectoryList) Select(name string) { defer logging.PanicHandler() select { - case <-time.After(dirlist.UiConfig().DirListDelay): + case <-time.After(dirlist.UiConfig(name).DirListDelay): newStore := true for _, s := range dirlist.store.List() { if s == dirlist.selecting { @@ -218,7 +221,7 @@ func (dirlist *DirectoryList) getDirString(name string, width int, recentUnseen formatted = runewidth.FillRight(formatted, width-len(s)) formatted = runewidth.Truncate(formatted, width-len(s), "…") } - for _, char := range dirlist.UiConfig().DirListFormat { + for _, char := range dirlist.UiConfig(name).DirListFormat { switch char { case '%': if percent { @@ -283,7 +286,7 @@ func (dirlist *DirectoryList) getRUEString(name string) string { func (dirlist *DirectoryList) Draw(ctx *ui.Context) { ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', - dirlist.UiConfig().GetStyle(config.STYLE_DIRLIST_DEFAULT)) + dirlist.UiConfig("").GetStyle(config.STYLE_DIRLIST_DEFAULT)) if dirlist.spinner.IsRunning() { dirlist.spinner.Draw(ctx) @@ -291,8 +294,8 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) { } if len(dirlist.dirs) == 0 { - style := dirlist.UiConfig().GetStyle(config.STYLE_DIRLIST_DEFAULT) - ctx.Printf(0, 0, style, dirlist.UiConfig().EmptyDirlist) + style := dirlist.UiConfig("").GetStyle(config.STYLE_DIRLIST_DEFAULT) + ctx.Printf(0, 0, style, dirlist.UiConfig("").EmptyDirlist) return } @@ -324,10 +327,10 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) { case 2: dirStyle = append(dirStyle, config.STYLE_DIRLIST_RECENT) } - style := dirlist.UiConfig().GetComposedStyle( + style := dirlist.UiConfig(name).GetComposedStyle( config.STYLE_DIRLIST_DEFAULT, dirStyle) if name == dirlist.selecting { - style = dirlist.UiConfig().GetComposedStyleSelected( + style = dirlist.UiConfig(name).GetComposedStyleSelected( config.STYLE_DIRLIST_DEFAULT, dirStyle) } ctx.Fill(0, row, textWidth, 1, ' ', style) diff --git a/widgets/dirtree.go b/widgets/dirtree.go index c3b80773..65fb3116 100644 --- a/widgets/dirtree.go +++ b/widgets/dirtree.go @@ -51,7 +51,7 @@ func (dt *DirectoryTree) UpdateList(done func([]string)) { func (dt *DirectoryTree) Draw(ctx *ui.Context) { ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', - dt.UiConfig().GetStyle(config.STYLE_DIRLIST_DEFAULT)) + dt.UiConfig("").GetStyle(config.STYLE_DIRLIST_DEFAULT)) if dt.DirectoryList.spinner.IsRunning() { dt.DirectoryList.spinner.Draw(ctx) @@ -60,8 +60,8 @@ func (dt *DirectoryTree) Draw(ctx *ui.Context) { n := dt.countVisible(dt.list) if n == 0 { - style := dt.UiConfig().GetStyle(config.STYLE_DIRLIST_DEFAULT) - ctx.Printf(0, 0, style, dt.UiConfig().EmptyDirlist) + style := dt.UiConfig("").GetStyle(config.STYLE_DIRLIST_DEFAULT) + ctx.Printf(0, 0, style, dt.UiConfig("").EmptyDirlist) return } @@ -104,10 +104,10 @@ func (dt *DirectoryTree) Draw(ctx *ui.Context) { case 2: dirStyle = append(dirStyle, config.STYLE_DIRLIST_RECENT) } - style := dt.UiConfig().GetComposedStyle( + style := dt.UiConfig(path).GetComposedStyle( config.STYLE_DIRLIST_DEFAULT, dirStyle) if i == dt.listIdx { - style = dt.UiConfig().GetComposedStyleSelected( + style = dt.UiConfig(path).GetComposedStyleSelected( config.STYLE_DIRLIST_DEFAULT, dirStyle) } ctx.Fill(0, row, textWidth, 1, ' ', style) diff --git a/widgets/msglist.go b/widgets/msglist.go index e505608a..935566f8 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -201,7 +201,7 @@ func (ml *MessageList) drawRow(textWidth int, ctx *ui.Context, uid uint32, row i // should implement a better per-message styling method // Check if we have any applicable ContextualUIConfigs confs := ml.aerc.conf.GetContextualUIConfigs() - uiConfig := acct.Directories().UiConfig() + uiConfig := acct.Directories().UiConfig(store.DirInfo.Name) for _, c := range confs { if c.ContextType == config.UI_CONTEXT_SUBJECT && msg.Envelope != nil { if c.Regex.Match([]byte(msg.Envelope.Subject)) { |