Add :detach command
Add a command for removing attachments from a composed message. Syntax is :detach [path], with path being an optional argument specifying the path of one existing attachment. If no path is specified, the first attachment is removed.
This commit is contained in:
parent
a669233614
commit
0ee7d30187
3 changed files with 79 additions and 0 deletions
widgets
|
@ -434,8 +434,28 @@ func writeAttachment(path string, writer *mail.Writer) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *Composer) GetAttachments() []string {
|
||||
return c.attachments
|
||||
}
|
||||
|
||||
func (c *Composer) AddAttachment(path string) {
|
||||
c.attachments = append(c.attachments, path)
|
||||
c.resetReview()
|
||||
}
|
||||
|
||||
func (c *Composer) DeleteAttachment(path string) error {
|
||||
for i, a := range c.attachments {
|
||||
if a == path {
|
||||
c.attachments = append(c.attachments[:i], c.attachments[i+1:]...)
|
||||
c.resetReview()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return errors.New("attachment does not exist")
|
||||
}
|
||||
|
||||
func (c *Composer) resetReview() {
|
||||
if c.review != nil {
|
||||
c.grid.RemoveChild(c.review)
|
||||
c.review = newReviewMessage(c, nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue