2019-07-17 09:35:50 +02:00
|
|
|
package account
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2022-02-22 20:10:54 +01:00
|
|
|
|
2021-11-05 10:19:46 +01:00
|
|
|
"git.sr.ht/~rjarry/aerc/widgets"
|
2019-07-17 09:35:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Clear struct{}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
register(Clear{})
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +02:00
|
|
|
func (Clear) Aliases() []string {
|
2019-07-17 09:35:50 +02:00
|
|
|
return []string{"clear"}
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +02:00
|
|
|
func (Clear) Complete(aerc *widgets.Aerc, args []string) []string {
|
2019-07-17 09:35:50 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +02:00
|
|
|
func (Clear) Execute(aerc *widgets.Aerc, args []string) error {
|
2019-07-17 09:35:50 +02: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()
|
2022-02-22 20:10:54 +01:00
|
|
|
aerc.ClearExtraStatus()
|
2019-07-17 09:35:50 +02:00
|
|
|
return nil
|
|
|
|
}
|