Skip to content

Commit

Permalink
Fix: Message view not updating when deleting messages from search (#395)
Browse files Browse the repository at this point in the history
* Fix message view not updating when deleting messages from search

* Move logic to after SQL execution and prune if > 200 messages
  • Loading branch information
avesst authored Nov 30, 2024
1 parent aabb2ac commit 6e44691
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/storage/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/araddon/dateparse"
"github.com/axllent/mailpit/internal/logger"
"github.com/axllent/mailpit/internal/tools"
"github.com/axllent/mailpit/server/websockets"
"github.com/leporo/sqlf"
)

Expand Down Expand Up @@ -201,6 +202,18 @@ func DeleteSearch(search, timezone string) error {

dbLastAction = time.Now()

// broadcast changes
if len(ids) > 200 {
websockets.Broadcast("prune", nil)
} else {
for _, id := range ids {
d := struct {
ID string
}{ID: id}
websockets.Broadcast("delete", d)
}
}

addDeletedSize(int64(deleteSize))

logMessagesDeleted(total)
Expand Down

0 comments on commit 6e44691

Please sign in to comment.