[geary: 1/13] Filters messages from the conversation set who contain the \DELETED flag.



commit 5ae650080c0f747b716b9736528de208b32adf0c
Author: James Magahern <james magahern com>
Date:   Sun Oct 7 17:53:27 2018 -0700

    Filters messages from the conversation set who contain the \DELETED flag.

 src/engine/api/geary-email-flags.vala                         | 8 ++++++++
 src/engine/app/app-conversation-monitor.vala                  | 4 +++-
 src/engine/app/app-conversation.vala                          | 5 +++++
 src/engine/app/conversation-monitor/app-conversation-set.vala | 2 +-
 src/engine/imap/api/imap-email-flags.vala                     | 9 +++++++++
 src/engine/imap/message/imap-message-flag.vala                | 6 +++++-
 6 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/src/engine/api/geary-email-flags.vala b/src/engine/api/geary-email-flags.vala
index c5d705e3..0831c8d5 100644
--- a/src/engine/api/geary-email-flags.vala
+++ b/src/engine/api/geary-email-flags.vala
@@ -30,6 +30,10 @@ public class Geary.EmailFlags : Geary.NamedFlags {
     public static NamedFlag DRAFT { owned get {
         return new NamedFlag("DRAFT");
     } }
+
+    public static NamedFlag DELETED { owned get {
+        return new NamedFlag("DELETED");
+    } }
     
     /// Signifies a message in our outbox that has been sent but we're still
     /// keeping around for other purposes, i.e. pushing up to Sent Mail.
@@ -73,5 +77,9 @@ public class Geary.EmailFlags : Geary.NamedFlags {
     public inline bool is_outbox_sent() {
         return contains(OUTBOX_SENT);
     }
+
+    public inline bool is_deleted() {
+        return contains(DELETED);
+    }
 }
 
diff --git a/src/engine/app/app-conversation-monitor.vala b/src/engine/app/app-conversation-monitor.vala
index eacb9f6e..6a7b01ed 100644
--- a/src/engine/app/app-conversation-monitor.vala
+++ b/src/engine/app/app-conversation-monitor.vala
@@ -685,8 +685,10 @@ public class Geary.App.ConversationMonitor : BaseObject {
             if (!job.emails.has_key(email.id)) {
                 job.emails.set(email.id, email);
 
+                // Expand conversations whose messages have ancestors, and aren't marked
+                // for deletion.
                 Gee.Set<RFC822.MessageID>? ancestors = email.get_ancestors();
-                if (ancestors != null) {
+                if (ancestors != null && !email.email_flags.is_deleted()) {
                     Geary.traverse<RFC822.MessageID>(ancestors)
                         .filter(id => !new_message_ids.contains(id))
                         .add_all_to(new_message_ids);
diff --git a/src/engine/app/app-conversation.vala b/src/engine/app/app-conversation.vala
index 931bfcce..77dd4543 100644
--- a/src/engine/app/app-conversation.vala
+++ b/src/engine/app/app-conversation.vala
@@ -233,6 +233,11 @@ public class Geary.App.Conversation : BaseObject {
             break;
         }
 
+        // Filter emails waiting to be expunged (\DELETED)
+        filtered = filtered.filter(
+            (e) => !e.email_flags.is_deleted()
+        );
+
         if (blacklist != null && !blacklist.is_empty) {
             if (blacklist.size == 1) {
                 FolderPath blacklist_path =
diff --git a/src/engine/app/conversation-monitor/app-conversation-set.vala 
b/src/engine/app/conversation-monitor/app-conversation-set.vala
index 91a557a4..490b600f 100644
--- a/src/engine/app/conversation-monitor/app-conversation-set.vala
+++ b/src/engine/app/conversation-monitor/app-conversation-set.vala
@@ -127,7 +127,7 @@ private class Geary.App.ConversationSet : BaseObject {
                     email, base_folder, known_paths,
                     out added_conversation
                 );
-            }
+            } 
 
             if (conversation != null) {
                 if (added_conversation) {
diff --git a/src/engine/imap/api/imap-email-flags.vala b/src/engine/imap/api/imap-email-flags.vala
index ee0d3ef6..1d9bb13d 100644
--- a/src/engine/imap/api/imap-email-flags.vala
+++ b/src/engine/imap/api/imap-email-flags.vala
@@ -21,6 +21,9 @@ public class Geary.Imap.EmailFlags : Geary.EmailFlags {
         
         if (flags.contains(MessageFlag.DRAFT))
             add(DRAFT);
+
+        if (flags.contains(MessageFlag.DELETED))
+            add(DELETED);
     }
     
     /**
@@ -66,6 +69,9 @@ public class Geary.Imap.EmailFlags : Geary.EmailFlags {
             
             if (flag.equal_to(DRAFT))
                 message_flags.add(MessageFlag.DRAFT);
+            
+            if (flag.equal_to(DELETED)) 
+                message_flags.add(MessageFlag.DELETED);
         }
         
         base.notify_added(added);
@@ -84,6 +90,9 @@ public class Geary.Imap.EmailFlags : Geary.EmailFlags {
             
             if (flag.equal_to(DRAFT))
                 message_flags.remove(MessageFlag.DRAFT);
+
+            if (flag.equal_to(DELETED))
+                message_flags.remove(MessageFlag.DELETED);
         }
         
         base.notify_removed(removed);
diff --git a/src/engine/imap/message/imap-message-flag.vala b/src/engine/imap/message/imap-message-flag.vala
index 5a73c5dc..582a539c 100644
--- a/src/engine/imap/message/imap-message-flag.vala
+++ b/src/engine/imap/message/imap-message-flag.vala
@@ -62,7 +62,7 @@ public class Geary.Imap.MessageFlag : Geary.Imap.Flag {
         
         return _seen;
     } }
-    
+
     private static MessageFlag? _allows_new = null;
     public static MessageFlag ALLOWS_NEW { get {
         if (_allows_new == null)
@@ -115,6 +115,8 @@ public class Geary.Imap.MessageFlag : Geary.Imap.Flag {
                 msg_flags_add.add(MessageFlag.LOAD_REMOTE_IMAGES);
             if (email_flags_add.contains(Geary.EmailFlags.DRAFT))
                 msg_flags_add.add(MessageFlag.DRAFT);
+            if (email_flags_add.contains(Geary.EmailFlags.DELETED))
+                msg_flags_add.add(MessageFlag.DELETED);
         }
 
         if (email_flags_remove != null) {
@@ -126,6 +128,8 @@ public class Geary.Imap.MessageFlag : Geary.Imap.Flag {
                 msg_flags_remove.add(MessageFlag.LOAD_REMOTE_IMAGES);
             if (email_flags_remove.contains(Geary.EmailFlags.DRAFT))
                 msg_flags_remove.add(MessageFlag.DRAFT);
+            if (email_flags_remove.contains(Geary.EmailFlags.DELETED))
+                msg_flags_remove.add(MessageFlag.DELETED);
         }
     }
     


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