Commit d6ca47ba authored by Michael Gratton's avatar Michael Gratton 🤞

Ensure ImapDb.Folder updates email total when marking removed

Updates the total email count as well as the unread email count when
adding or removing the removed frag from messages.

This prevents the ConversationMonitor freaking out between removing a
message from the base folder and the IMAP server notifting that the
change has occurred.
parent 3a44628d
Pipeline #73057 failed with stages
in 6 minutes and 48 seconds
...@@ -1057,6 +1057,7 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics { ...@@ -1057,6 +1057,7 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
public async Gee.Set<ImapDB.EmailIdentifier>? mark_removed_async( public async Gee.Set<ImapDB.EmailIdentifier>? mark_removed_async(
Gee.Collection<ImapDB.EmailIdentifier>? ids, bool mark_removed, Cancellable? cancellable) Gee.Collection<ImapDB.EmailIdentifier>? ids, bool mark_removed, Cancellable? cancellable)
throws Error { throws Error {
int total_changed = 0;
int unread_count = 0; int unread_count = 0;
Gee.Set<ImapDB.EmailIdentifier> removed_ids = new Gee.HashSet<ImapDB.EmailIdentifier>(); Gee.Set<ImapDB.EmailIdentifier> removed_ids = new Gee.HashSet<ImapDB.EmailIdentifier>();
yield db.exec_transaction_async(Db.TransactionType.RW, (cx) => { yield db.exec_transaction_async(Db.TransactionType.RW, (cx) => {
...@@ -1069,6 +1070,7 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics { ...@@ -1069,6 +1070,7 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
if (locs == null || locs.size == 0) if (locs == null || locs.size == 0)
return Db.TransactionOutcome.DONE; return Db.TransactionOutcome.DONE;
total_changed = locs.size;
unread_count = do_get_unread_count_for_ids(cx, ids, cancellable); unread_count = do_get_unread_count_for_ids(cx, ids, cancellable);
Gee.HashSet<Imap.UID> uids = new Gee.HashSet<Imap.UID>(); Gee.HashSet<Imap.UID> uids = new Gee.HashSet<Imap.UID>();
...@@ -1077,14 +1079,26 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics { ...@@ -1077,14 +1079,26 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
removed_ids.add(location.email_id); removed_ids.add(location.email_id);
} }
if (uids.size > 0) do_mark_unmark_removed(cx, uids, mark_removed, cancellable);
do_mark_unmark_removed(cx, uids, mark_removed, cancellable);
do_add_to_unread_count(cx, -unread_count, cancellable); do_add_to_unread_count(cx, -unread_count, cancellable);
return Db.TransactionOutcome.DONE; return Db.TransactionOutcome.DONE;
}, cancellable); }, cancellable);
// Update the folder properties so client sees the changes
// right away
// Email total
if (mark_removed) {
total_changed = -total_changed;
}
int total = this.properties.select_examine_messages + total_changed;
if (total >= 0) {
this.properties.set_select_examine_message_count(total);
}
// Unread total
if (unread_count > 0) if (unread_count > 0)
properties.set_status_unseen(properties.email_unread - unread_count); properties.set_status_unseen(properties.email_unread - unread_count);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment