2022-02-24 00:41:13 +01:00
|
|
|
package msg
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2022-03-18 22:35:33 +01:00
|
|
|
"git.sr.ht/~rjarry/aerc/lib/statusline"
|
2022-10-07 18:00:31 +02:00
|
|
|
"git.sr.ht/~rjarry/aerc/lib/ui"
|
2022-02-24 00:41:13 +01: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-07-05 21:48:38 +02:00
|
|
|
store.SetThreadedView(!store.ThreadedView())
|
|
|
|
acct.SetStatus(statusline.Threading(store.ThreadedView()))
|
2022-10-07 18:00:31 +02:00
|
|
|
ui.Invalidate()
|
2022-02-24 00:41:13 +01:00
|
|
|
return nil
|
|
|
|
}
|