mail: filter messages in Trash from unread count
When moving an unread message to the Trash, a B_QUERY_UPDATE is triggered, resulting in a global notification popup of the new message count - inclusive of all messages on the volume. The on-disk location of a mail message is now checked to determine if it's in the Trash, before incrementing or decrementing the unread mail count (and triggering a notification). This effectively filters out notifications for deleting unread e-mail messages. The Deskbar view uses the same logic to display the Mail/No Mail icon. The B_QUERY_UPDATE handler here has been adjusted to match. Additionally, unread mail messages in the trash are now filtered when mail_daemon starts. This ensures that an accurate initial unread count is set. Fixes #18252 Fixes #17510 Change-Id: I9b8ec0b2b1f1ddb07797f8a9bedf32811f26f137 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6136 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com> Tested-by: Automation <automation@haiku-os.org>
This commit is contained in:
parent
4f1e67e18e
commit
fbc2a57b09
@ -246,35 +246,27 @@ DeskbarView::MessageReceived(BMessage* message)
|
||||
|
||||
case B_QUERY_UPDATE:
|
||||
{
|
||||
int32 what;
|
||||
dev_t device;
|
||||
ino_t directory;
|
||||
const char *name;
|
||||
entry_ref ref;
|
||||
message->FindInt32("opcode", &what);
|
||||
message->FindInt32("device", &device);
|
||||
message->FindInt64("directory", &directory);
|
||||
switch (what) {
|
||||
int32 opcode;
|
||||
message->FindInt32("opcode", &opcode);
|
||||
|
||||
switch (opcode) {
|
||||
case B_ENTRY_CREATED:
|
||||
if (message->FindString("name", &name) == B_OK) {
|
||||
ref.device = device;
|
||||
ref.directory = directory;
|
||||
ref.set_name(name);
|
||||
if (!_EntryInTrash(&ref))
|
||||
case B_ENTRY_REMOVED:
|
||||
{
|
||||
entry_ref ref;
|
||||
message->FindInt32("device", &ref.device);
|
||||
message->FindInt64("directory", &ref.directory);
|
||||
|
||||
if (!_EntryInTrash(&ref)) {
|
||||
if (opcode == B_ENTRY_CREATED)
|
||||
fNewMessages++;
|
||||
else
|
||||
fNewMessages--;
|
||||
}
|
||||
break;
|
||||
case B_ENTRY_REMOVED:
|
||||
node_ref node;
|
||||
node.device = device;
|
||||
node.node = directory;
|
||||
BDirectory dir(&node);
|
||||
BEntry entry(&dir, NULL);
|
||||
entry.GetRef(&ref);
|
||||
if (!_EntryInTrash(&ref))
|
||||
fNewMessages--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fStatus = fNewMessages > 0 ? kStatusNewMail : kStatusNoMail;
|
||||
Invalidate();
|
||||
break;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <FindDirectory.h>
|
||||
#include <fs_index.h>
|
||||
#include <IconUtils.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <NodeMonitor.h>
|
||||
#include <Notification.h>
|
||||
#include <Path.h>
|
||||
@ -376,14 +377,26 @@ MailDaemonApplication::MessageReceived(BMessage* msg)
|
||||
{
|
||||
int32 previousCount = fNewMessages;
|
||||
|
||||
int32 opcode = msg->GetInt32("opcode", -1);
|
||||
int32 opcode;
|
||||
msg->FindInt32("opcode", &opcode);
|
||||
|
||||
switch (opcode) {
|
||||
case B_ENTRY_CREATED:
|
||||
fNewMessages++;
|
||||
break;
|
||||
case B_ENTRY_REMOVED:
|
||||
fNewMessages--;
|
||||
{
|
||||
entry_ref ref;
|
||||
msg->FindInt32("device", &ref.device);
|
||||
msg->FindInt64("directory", &ref.directory);
|
||||
BEntry entry(&ref);
|
||||
|
||||
if (!_IsEntryInTrash(entry)) {
|
||||
if (opcode == B_ENTRY_CREATED)
|
||||
fNewMessages++;
|
||||
else
|
||||
fNewMessages--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@ -796,8 +809,10 @@ MailDaemonApplication::_InitNewMessagesCount()
|
||||
query->Fetch();
|
||||
|
||||
BEntry entry;
|
||||
while (query->GetNextEntry(&entry) == B_OK)
|
||||
fNewMessages++;
|
||||
while (query->GetNextEntry(&entry) == B_OK) {
|
||||
if (!_IsEntryInTrash(entry))
|
||||
fNewMessages++;
|
||||
}
|
||||
|
||||
fQueries.AddItem(query);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user