[geary/mjog/invert-folder-class-hierarchy: 27/72] Geary.ImapEngine: Ensure folder counts updated on flag updates




commit 890807fccc0cf4c2fbb8b4a08d21c7bf14819634
Author: Michael Gratton <mike vee net>
Date:   Sun Feb 14 19:58:44 2021 +1100

    Geary.ImapEngine: Ensure folder counts updated on flag updates
    
    Ensure MarkEmail and ReplayUpdate also refresh folder email counts.

 src/engine/imap-engine/replay-ops/imap-engine-mark-email.vala    | 9 ++++++---
 src/engine/imap-engine/replay-ops/imap-engine-replay-update.vala | 1 +
 2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/engine/imap-engine/replay-ops/imap-engine-mark-email.vala 
b/src/engine/imap-engine/replay-ops/imap-engine-mark-email.vala
index 0f93592e0..569d4822b 100644
--- a/src/engine/imap-engine/replay-ops/imap-engine-mark-email.vala
+++ b/src/engine/imap-engine/replay-ops/imap-engine-mark-email.vala
@@ -45,14 +45,17 @@ private class Geary.ImapEngine.MarkEmail : Geary.ImapEngine.SendReplayOperation
         if (original_flags == null || original_flags.size == 0)
             return ReplayOperation.Status.COMPLETED;
 
-        yield engine.local_folder.mark_email_async(original_flags.keys, flags_to_add, flags_to_remove,
-            cancellable);
+        yield this.engine.local_folder.mark_email_async(
+            original_flags.keys, flags_to_add, flags_to_remove, cancellable
+        );
+        yield this.engine.update_email_counts(this.cancellable);
 
         // Notify using flags from DB.
         Gee.Map<EmailIdentifier, Geary.EmailFlags>? map = yield engine.local_folder.get_email_flags_async(
             original_flags.keys, cancellable);
-        if (map != null && map.size > 0)
+        if (map != null && !map.is_empty) {
             engine.email_flags_changed(map);
+        }
 
         return ReplayOperation.Status.CONTINUE;
     }
diff --git a/src/engine/imap-engine/replay-ops/imap-engine-replay-update.vala 
b/src/engine/imap-engine/replay-ops/imap-engine-replay-update.vala
index f6a58dee8..16c878ba7 100644
--- a/src/engine/imap-engine/replay-ops/imap-engine-replay-update.vala
+++ b/src/engine/imap-engine/replay-ops/imap-engine-replay-update.vala
@@ -60,6 +60,7 @@ private class Geary.ImapEngine.ReplayUpdate : Geary.ImapEngine.ReplayOperation {
                 changed_map.set(id, new Imap.EmailFlags(message_flags));
 
                 yield this.owner.local_folder.set_email_flags_async(changed_map, null);
+                yield this.owner.update_email_counts(null);
 
                 // only notify if the email is not marked for deletion
                 try {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]