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>
This commit is contained in:
parent
0db924dc14
commit
e1b62db583
4 changed files with 28 additions and 24 deletions
|
@ -42,7 +42,7 @@ type AccountView struct {
|
||||||
|
|
||||||
func (acct *AccountView) UiConfig() *config.UIConfig {
|
func (acct *AccountView) UiConfig() *config.UIConfig {
|
||||||
if dirlist := acct.Directories(); dirlist != nil {
|
if dirlist := acct.Directories(); dirlist != nil {
|
||||||
return dirlist.UiConfig()
|
return dirlist.UiConfig("")
|
||||||
}
|
}
|
||||||
return acct.uiConf
|
return acct.uiConf
|
||||||
}
|
}
|
||||||
|
@ -291,16 +291,17 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
|
||||||
if store, ok := acct.dirlist.MsgStore(msg.Info.Name); ok {
|
if store, ok := acct.dirlist.MsgStore(msg.Info.Name); ok {
|
||||||
store.Update(msg)
|
store.Update(msg)
|
||||||
} else {
|
} else {
|
||||||
|
name := msg.Info.Name
|
||||||
store = lib.NewMessageStore(acct.worker, msg.Info,
|
store = lib.NewMessageStore(acct.worker, msg.Info,
|
||||||
acct.GetSortCriteria(),
|
acct.GetSortCriteria(),
|
||||||
acct.UiConfig().ThreadingEnabled,
|
acct.dirlist.UiConfig(name).ThreadingEnabled,
|
||||||
acct.UiConfig().ForceClientThreads,
|
acct.dirlist.UiConfig(name).ForceClientThreads,
|
||||||
acct.UiConfig().ClientThreadsDelay,
|
acct.dirlist.UiConfig(name).ClientThreadsDelay,
|
||||||
func(msg *models.MessageInfo) {
|
func(msg *models.MessageInfo) {
|
||||||
acct.conf.Triggers.ExecNewEmail(acct.acct,
|
acct.conf.Triggers.ExecNewEmail(acct.acct,
|
||||||
acct.conf, msg)
|
acct.conf, msg)
|
||||||
}, func() {
|
}, func() {
|
||||||
if acct.UiConfig().NewMessageBell {
|
if acct.dirlist.UiConfig(name).NewMessageBell {
|
||||||
acct.host.Beep()
|
acct.host.Beep()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -43,7 +43,7 @@ type DirectoryLister interface {
|
||||||
|
|
||||||
FilterDirs([]string, []string, bool) []string
|
FilterDirs([]string, []string, bool) []string
|
||||||
|
|
||||||
UiConfig() *config.UIConfig
|
UiConfig(string) *config.UIConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type DirectoryList struct {
|
type DirectoryList struct {
|
||||||
|
@ -78,7 +78,7 @@ func NewDirectoryList(conf *config.AercConfig, acctConf *config.AccountConfig,
|
||||||
skipSelectCancel: cancel,
|
skipSelectCancel: cancel,
|
||||||
uiConf: uiConfMap,
|
uiConf: uiConfMap,
|
||||||
}
|
}
|
||||||
uiConf := dirlist.UiConfig()
|
uiConf := dirlist.UiConfig("")
|
||||||
dirlist.spinner = NewSpinner(uiConf)
|
dirlist.spinner = NewSpinner(uiConf)
|
||||||
dirlist.spinner.OnInvalidate(func(_ ui.Drawable) {
|
dirlist.spinner.OnInvalidate(func(_ ui.Drawable) {
|
||||||
dirlist.Invalidate()
|
dirlist.Invalidate()
|
||||||
|
@ -92,15 +92,18 @@ func NewDirectoryList(conf *config.AercConfig, acctConf *config.AccountConfig,
|
||||||
return dirlist
|
return dirlist
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dirlist *DirectoryList) UiConfig() *config.UIConfig {
|
func (dirlist *DirectoryList) UiConfig(dir string) *config.UIConfig {
|
||||||
if ui, ok := dirlist.uiConf[dirlist.Selected()]; ok {
|
if dir == "" {
|
||||||
|
dir = dirlist.Selected()
|
||||||
|
}
|
||||||
|
if ui, ok := dirlist.uiConf[dir]; ok {
|
||||||
return ui
|
return ui
|
||||||
}
|
}
|
||||||
ui := dirlist.aercConf.GetUiConfig(map[config.ContextType]string{
|
ui := dirlist.aercConf.GetUiConfig(map[config.ContextType]string{
|
||||||
config.UI_CONTEXT_ACCOUNT: dirlist.acctConf.Name,
|
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
|
return ui
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +157,7 @@ func (dirlist *DirectoryList) Select(name string) {
|
||||||
defer logging.PanicHandler()
|
defer logging.PanicHandler()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(dirlist.UiConfig().DirListDelay):
|
case <-time.After(dirlist.UiConfig(name).DirListDelay):
|
||||||
newStore := true
|
newStore := true
|
||||||
for _, s := range dirlist.store.List() {
|
for _, s := range dirlist.store.List() {
|
||||||
if s == dirlist.selecting {
|
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.FillRight(formatted, width-len(s))
|
||||||
formatted = runewidth.Truncate(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 {
|
switch char {
|
||||||
case '%':
|
case '%':
|
||||||
if percent {
|
if percent {
|
||||||
|
@ -283,7 +286,7 @@ func (dirlist *DirectoryList) getRUEString(name string) string {
|
||||||
|
|
||||||
func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
|
func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
|
||||||
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ',
|
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() {
|
if dirlist.spinner.IsRunning() {
|
||||||
dirlist.spinner.Draw(ctx)
|
dirlist.spinner.Draw(ctx)
|
||||||
|
@ -291,8 +294,8 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(dirlist.dirs) == 0 {
|
if len(dirlist.dirs) == 0 {
|
||||||
style := dirlist.UiConfig().GetStyle(config.STYLE_DIRLIST_DEFAULT)
|
style := dirlist.UiConfig("").GetStyle(config.STYLE_DIRLIST_DEFAULT)
|
||||||
ctx.Printf(0, 0, style, dirlist.UiConfig().EmptyDirlist)
|
ctx.Printf(0, 0, style, dirlist.UiConfig("").EmptyDirlist)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,10 +327,10 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
|
||||||
case 2:
|
case 2:
|
||||||
dirStyle = append(dirStyle, config.STYLE_DIRLIST_RECENT)
|
dirStyle = append(dirStyle, config.STYLE_DIRLIST_RECENT)
|
||||||
}
|
}
|
||||||
style := dirlist.UiConfig().GetComposedStyle(
|
style := dirlist.UiConfig(name).GetComposedStyle(
|
||||||
config.STYLE_DIRLIST_DEFAULT, dirStyle)
|
config.STYLE_DIRLIST_DEFAULT, dirStyle)
|
||||||
if name == dirlist.selecting {
|
if name == dirlist.selecting {
|
||||||
style = dirlist.UiConfig().GetComposedStyleSelected(
|
style = dirlist.UiConfig(name).GetComposedStyleSelected(
|
||||||
config.STYLE_DIRLIST_DEFAULT, dirStyle)
|
config.STYLE_DIRLIST_DEFAULT, dirStyle)
|
||||||
}
|
}
|
||||||
ctx.Fill(0, row, textWidth, 1, ' ', style)
|
ctx.Fill(0, row, textWidth, 1, ' ', style)
|
||||||
|
|
|
@ -51,7 +51,7 @@ func (dt *DirectoryTree) UpdateList(done func([]string)) {
|
||||||
|
|
||||||
func (dt *DirectoryTree) Draw(ctx *ui.Context) {
|
func (dt *DirectoryTree) Draw(ctx *ui.Context) {
|
||||||
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ',
|
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() {
|
if dt.DirectoryList.spinner.IsRunning() {
|
||||||
dt.DirectoryList.spinner.Draw(ctx)
|
dt.DirectoryList.spinner.Draw(ctx)
|
||||||
|
@ -60,8 +60,8 @@ func (dt *DirectoryTree) Draw(ctx *ui.Context) {
|
||||||
|
|
||||||
n := dt.countVisible(dt.list)
|
n := dt.countVisible(dt.list)
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
style := dt.UiConfig().GetStyle(config.STYLE_DIRLIST_DEFAULT)
|
style := dt.UiConfig("").GetStyle(config.STYLE_DIRLIST_DEFAULT)
|
||||||
ctx.Printf(0, 0, style, dt.UiConfig().EmptyDirlist)
|
ctx.Printf(0, 0, style, dt.UiConfig("").EmptyDirlist)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,10 +104,10 @@ func (dt *DirectoryTree) Draw(ctx *ui.Context) {
|
||||||
case 2:
|
case 2:
|
||||||
dirStyle = append(dirStyle, config.STYLE_DIRLIST_RECENT)
|
dirStyle = append(dirStyle, config.STYLE_DIRLIST_RECENT)
|
||||||
}
|
}
|
||||||
style := dt.UiConfig().GetComposedStyle(
|
style := dt.UiConfig(path).GetComposedStyle(
|
||||||
config.STYLE_DIRLIST_DEFAULT, dirStyle)
|
config.STYLE_DIRLIST_DEFAULT, dirStyle)
|
||||||
if i == dt.listIdx {
|
if i == dt.listIdx {
|
||||||
style = dt.UiConfig().GetComposedStyleSelected(
|
style = dt.UiConfig(path).GetComposedStyleSelected(
|
||||||
config.STYLE_DIRLIST_DEFAULT, dirStyle)
|
config.STYLE_DIRLIST_DEFAULT, dirStyle)
|
||||||
}
|
}
|
||||||
ctx.Fill(0, row, textWidth, 1, ' ', style)
|
ctx.Fill(0, row, textWidth, 1, ' ', style)
|
||||||
|
|
|
@ -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
|
// should implement a better per-message styling method
|
||||||
// Check if we have any applicable ContextualUIConfigs
|
// Check if we have any applicable ContextualUIConfigs
|
||||||
confs := ml.aerc.conf.GetContextualUIConfigs()
|
confs := ml.aerc.conf.GetContextualUIConfigs()
|
||||||
uiConfig := acct.Directories().UiConfig()
|
uiConfig := acct.Directories().UiConfig(store.DirInfo.Name)
|
||||||
for _, c := range confs {
|
for _, c := range confs {
|
||||||
if c.ContextType == config.UI_CONTEXT_SUBJECT && msg.Envelope != nil {
|
if c.ContextType == config.UI_CONTEXT_SUBJECT && msg.Envelope != nil {
|
||||||
if c.Regex.Match([]byte(msg.Envelope.Subject)) {
|
if c.Regex.Match([]byte(msg.Envelope.Subject)) {
|
||||||
|
|
Loading…
Reference in a new issue