2019-07-17 07:35:50 +00:00
|
|
|
package account
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"git.sr.ht/~sircmpwn/aerc/widgets"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Clear struct{}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
register(Clear{})
|
|
|
|
}
|
|
|
|
|
2019-09-03 19:34:03 +00:00
|
|
|
func (Clear) Aliases() []string {
|
2019-07-17 07:35:50 +00:00
|
|
|
return []string{"clear"}
|
|
|
|
}
|
|
|
|
|
2019-09-03 19:34:03 +00:00
|
|
|
func (Clear) Complete(aerc *widgets.Aerc, args []string) []string {
|
2019-07-17 07:35:50 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-03 19:34:03 +00:00
|
|
|
func (Clear) Execute(aerc *widgets.Aerc, args []string) error {
|
2019-07-17 07:35:50 +00:00
|
|
|
acct := aerc.SelectedAccount()
|
|
|
|
if acct == nil {
|
|
|
|
return errors.New("No account selected")
|
|
|
|
}
|
|
|
|
store := acct.Store()
|
|
|
|
if store == nil {
|
|
|
|
return errors.New("Cannot perform action. Messages still loading")
|
|
|
|
}
|
|
|
|
store.ApplyClear()
|
|
|
|
aerc.SetStatus("Clear complete.")
|
|
|
|
return nil
|
|
|
|
}
|