commands: Don't crash when store is nil
On a slow network connection, running these commands without this guard will cause aerc to panic. Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
This commit is contained in:
parent
d85f671bdf
commit
8bb115dbae
|
@ -51,6 +51,9 @@ func (_ SearchFilter) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return errors.New("No account selected")
|
||||
}
|
||||
store := acct.Store()
|
||||
if store == nil {
|
||||
return errors.New("Cannot perform action. Messages still loading")
|
||||
}
|
||||
aerc.SetStatus("Searching...")
|
||||
store.Search(criteria, func(uids []uint32) {
|
||||
aerc.SetStatus("Search complete.")
|
||||
|
|
|
@ -41,11 +41,14 @@ func (_ Archive) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if acct == nil {
|
||||
return errors.New("No account selected")
|
||||
}
|
||||
store := widget.Store()
|
||||
if store == nil {
|
||||
return errors.New("Cannot perform action. Messages still loading")
|
||||
}
|
||||
msg, err := widget.SelectedMessage()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
store := widget.Store()
|
||||
archiveDir := acct.AccountConfig().Archive
|
||||
store.Next()
|
||||
acct.Messages().Scroll()
|
||||
|
|
|
@ -44,11 +44,14 @@ func (_ Copy) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
}
|
||||
|
||||
widget := aerc.SelectedTab().(widgets.ProvidesMessage)
|
||||
store := widget.Store()
|
||||
if store == nil {
|
||||
return errors.New("Cannot perform action. Messages still loading")
|
||||
}
|
||||
msg, err := widget.SelectedMessage()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
store := widget.Store()
|
||||
store.Copy([]uint32{msg.Uid}, args[optind], createParents, func(
|
||||
msg types.WorkerMessage) {
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@ func (_ Delete) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
return errors.New("No account selected")
|
||||
}
|
||||
store := widget.Store()
|
||||
if store == nil {
|
||||
return errors.New("Cannot perform action. Messages still loading")
|
||||
}
|
||||
msg, err := widget.SelectedMessage()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -49,11 +49,14 @@ func (_ Move) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
if acct == nil {
|
||||
return errors.New("No account selected")
|
||||
}
|
||||
store := widget.Store()
|
||||
if store == nil {
|
||||
return errors.New("Cannot perform action. Messages still loading")
|
||||
}
|
||||
msg, err := widget.SelectedMessage()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
store := widget.Store()
|
||||
_, isMsgView := widget.(*widgets.MessageViewer)
|
||||
if isMsgView {
|
||||
aerc.RemoveTab(widget)
|
||||
|
|
|
@ -112,6 +112,9 @@ func (_ Pipe) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
|
||||
if pipeFull {
|
||||
store := provider.Store()
|
||||
if store == nil {
|
||||
return errors.New("Cannot perform action. Messages still loading")
|
||||
}
|
||||
msg, err := provider.SelectedMessage()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -30,11 +30,14 @@ func (_ Read) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
}
|
||||
|
||||
widget := aerc.SelectedTab().(widgets.ProvidesMessage)
|
||||
store := widget.Store()
|
||||
if store == nil {
|
||||
return errors.New("Cannot perform action. Messages still loading")
|
||||
}
|
||||
msg, err := widget.SelectedMessage()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
store := widget.Store()
|
||||
store.Read([]uint32{msg.Uid}, args[0] == "read", func(
|
||||
msg types.WorkerMessage) {
|
||||
|
||||
|
|
|
@ -60,6 +60,9 @@ func (_ reply) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
conf := acct.AccountConfig()
|
||||
us, _ := gomail.ParseAddress(conf.From)
|
||||
store := widget.Store()
|
||||
if store == nil {
|
||||
return errors.New("Cannot perform action. Messages still loading")
|
||||
}
|
||||
msg, err := widget.SelectedMessage()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue