2022-02-23 23:41:13 +00:00
|
|
|
package msg
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2022-03-18 21:35:33 +00:00
|
|
|
"git.sr.ht/~rjarry/aerc/lib/statusline"
|
2022-02-23 23:41:13 +00:00
|
|
|
"git.sr.ht/~rjarry/aerc/widgets"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ToggleThreads struct{}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
register(ToggleThreads{})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ToggleThreads) Aliases() []string {
|
|
|
|
return []string{"toggle-threads"}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ToggleThreads) Complete(aerc *widgets.Aerc, args []string) []string {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ToggleThreads) Execute(aerc *widgets.Aerc, args []string) error {
|
|
|
|
if len(args) != 1 {
|
|
|
|
return errors.New("Usage: toggle-threads")
|
|
|
|
}
|
|
|
|
h := newHelper(aerc)
|
|
|
|
acct, err := h.account()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
store, err := h.store()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-04-15 22:22:20 +00:00
|
|
|
defer store.Reselect(store.Selected())
|
2022-02-23 23:41:13 +00:00
|
|
|
store.SetBuildThreads(!store.BuildThreads())
|
2022-03-18 21:35:33 +00:00
|
|
|
acct.SetStatus(statusline.Threading(store.BuildThreads()))
|
2022-02-23 23:41:13 +00:00
|
|
|
acct.Messages().Invalidate()
|
|
|
|
return nil
|
|
|
|
}
|