Skip to content

Commit

Permalink
ui: correct some push status messages
Browse files Browse the repository at this point in the history
Upon success, commands :delete, :copy, :archive and :move show "Messages
deleted/copied/archived/moved" in the status bar, which is obviously
wrong if they are acting upon only one message. Make the success
notification for those commands explicitly agree with the actual number
of messages.

Signed-Off-By: inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
  • Loading branch information
agenbite authored and rjarry committed Nov 12, 2023
1 parent c13df79 commit 2d58976
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
8 changes: 7 additions & 1 deletion commands/msg/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ func archive(msgs []*models.MessageInfo, archiveType string) error {

wg.Wait()
if success {
handleDone(acct, next, "Messages archived.", store)
var s string
if len(uids) > 1 {
s = "%d messages archived to %s"
} else {
s = "%d message archived to %s"
}
handleDone(acct, next, fmt.Sprintf(s, len(uids), archiveDir), store)
}
}()
return nil
Expand Down
9 changes: 8 additions & 1 deletion commands/msg/copy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package msg

import (
"fmt"
"time"

"git.sr.ht/~rjarry/aerc/app"
Expand Down Expand Up @@ -41,7 +42,13 @@ func (c Copy) Execute(args []string) error {
) {
switch msg := msg.(type) {
case *types.Done:
app.PushStatus("Messages copied.", 10*time.Second)
var s string
if len(uids) > 1 {
s = "%d messages copied to %s"
} else {
s = "%d message copied to %s"
}
app.PushStatus(fmt.Sprintf(s, len(uids), c.Folder), 10*time.Second)
store.Marker().ClearVisualMark()
case *types.Error:
app.PushError(msg.Error.Error())
Expand Down
9 changes: 8 additions & 1 deletion commands/msg/delete.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package msg

import (
"fmt"
"time"

"git.sr.ht/~rjarry/aerc/app"
Expand Down Expand Up @@ -43,7 +44,13 @@ func (Delete) Execute(args []string) error {
store.Delete(uids, func(msg types.WorkerMessage) {
switch msg := msg.(type) {
case *types.Done:
app.PushStatus("Messages deleted.", 10*time.Second)
var s string
if len(uids) > 1 {
s = "%d messages deleted"
} else {
s = "%d message deleted"
}
app.PushStatus(fmt.Sprintf(s, len(uids)), 10*time.Second)
mv, isMsgView := h.msgProvider.(*app.MessageViewer)
if isMsgView {
if !config.Ui.NextMessageOnDelete {
Expand Down
9 changes: 8 additions & 1 deletion commands/msg/move.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package msg

import (
"fmt"
"time"

"git.sr.ht/~rjarry/aerc/app"
Expand Down Expand Up @@ -56,7 +57,13 @@ func (m Move) Execute(args []string) error {
) {
switch msg := msg.(type) {
case *types.Done:
handleDone(acct, next, "Messages moved to "+m.Folder, store)
var s string
if len(uids) > 1 {
s = "%d messages moved to %s"
} else {
s = "%d message moved to %s"
}
handleDone(acct, next, fmt.Sprintf(s, len(uids), m.Folder), store)
case *types.Error:
app.PushError(msg.Error.Error())
marker.Remark()
Expand Down

0 comments on commit 2d58976

Please sign in to comment.