2019-07-17 07:35:50 +00:00
|
|
|
package account
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2021-11-05 09:19:46 +00:00
|
|
|
"git.sr.ht/~rjarry/aerc/widgets"
|
2020-07-17 15:50:24 +00:00
|
|
|
"time"
|
2019-07-17 07:35:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
2020-07-08 16:03:34 +00:00
|
|
|
aerc.PushStatus("Clear complete.", 10*time.Second)
|
2019-07-17 07:35:50 +00:00
|
|
|
return nil
|
|
|
|
}
|