[geary/wip/all-mail-sticky-conversations: 1/2] Add base_folder property back to ConversationSet



commit 67bf1183e63b1af731f9db34aed75e631a8b7f95
Author: Michael Gratton <mike vee net>
Date:   Sat Feb 16 16:10:47 2019 +1100

    Add base_folder property back to ConversationSet
    
    Athough it was removed a while back, add it back since it is not only
    needed when adding conversations, but also when removing email from
    conversations to be able to detect when a conversation should be
    dropped.

 src/engine/app/app-conversation-monitor.vala       |  7 +++--
 .../conversation-monitor/app-conversation-set.vala | 26 ++++++++++++------
 test/engine/app/app-conversation-set-test.vala     | 31 ++++++++--------------
 3 files changed, 32 insertions(+), 32 deletions(-)
---
diff --git a/src/engine/app/app-conversation-monitor.vala b/src/engine/app/app-conversation-monitor.vala
index c9907688..be6d3e70 100644
--- a/src/engine/app/app-conversation-monitor.vala
+++ b/src/engine/app/app-conversation-monitor.vala
@@ -101,9 +101,7 @@ public class Geary.App.ConversationMonitor : BaseObject {
     }
 
     /** The set of all conversations loaded by the monitor. */
-    internal ConversationSet conversations {
-        get; private set; default = new ConversationSet();
-    }
+    internal ConversationSet conversations { get; private set; }
 
     /** The oldest message from the base folder in the loaded window. */
     internal EmailIdentifier? window_lowest {
@@ -263,6 +261,7 @@ public class Geary.App.ConversationMonitor : BaseObject {
         this.open_flags = open_flags;
         this.required_fields = required_fields | REQUIRED_FIELDS;
         this._min_window_count = min_window_count;
+        this.conversations = new ConversationSet(base_folder);
     }
 
     /**
@@ -726,7 +725,7 @@ public class Geary.App.ConversationMonitor : BaseObject {
             // Add them to the conversation set
             if (email_paths != null) {
                 this.conversations.add_all_emails(
-                    job.emails.values, email_paths, this.base_folder,
+                    job.emails.values, email_paths,
                     out added, out appended, out removed_due_to_merge
                 );
             }
diff --git a/src/engine/app/conversation-monitor/app-conversation-set.vala 
b/src/engine/app/conversation-monitor/app-conversation-set.vala
index 0d749bcc..5815c318 100644
--- a/src/engine/app/conversation-monitor/app-conversation-set.vala
+++ b/src/engine/app/conversation-monitor/app-conversation-set.vala
@@ -1,6 +1,6 @@
 /*
  * Copyright 2016 Software Freedom Conservancy Inc.
- * Copyright 2017 Michael Gratton <mike vee net>
+ * Copyright 2017-2019 Michael Gratton <mike vee net>
  *
  * This software is licensed under the GNU Lesser General Public License
  * (version 2.1 or later).  See the COPYING file in this distribution.
@@ -11,6 +11,10 @@
  */
 private class Geary.App.ConversationSet : BaseObject {
 
+
+    /** The base folder for this set of conversations. */
+    public Folder base_folder { get; private set; }
+
     /** Determines the number of conversations in the set. */
     public int size { get { return _conversations.size; } }
 
@@ -35,6 +39,16 @@ private class Geary.App.ConversationSet : BaseObject {
         = new Gee.HashMap<Geary.RFC822.MessageID, Conversation>();
 
 
+    /**
+     * Constructs a new conversation set.
+     *
+     * The `base_folder` argument is the base folder for the
+     * conversation monitor that owns this set.
+     */
+    public ConversationSet(Folder base_folder) {
+        this.base_folder = base_folder;
+    }
+
     public int get_email_count() {
         return email_id_map.size;
     }
@@ -60,8 +74,7 @@ private class Geary.App.ConversationSet : BaseObject {
      * needed. The collection `emails` contains the messages to be
      * added, and for each email in the collection, there should be an
      * entry in `id_to_paths` that indicates the folders each message
-     * is known to belong to. The folder `base_folder` is the base
-     * folder for the conversation monitor that owns this set.
+     * is known to belong to.
      *
      * The three collections returned include any conversation that
      * were created, any that had email appended to them (and the
@@ -70,7 +83,6 @@ private class Geary.App.ConversationSet : BaseObject {
      */
     public void add_all_emails(Gee.Collection<Email> emails,
                                Gee.MultiMap<EmailIdentifier, FolderPath> id_to_paths,
-                               Folder base_folder,
                                out Gee.Collection<Conversation> added,
                                out Gee.MultiMap<Conversation, Email> appended,
                                out Gee.Collection<Conversation> removed_due_to_merge) {
@@ -124,8 +136,7 @@ private class Geary.App.ConversationSet : BaseObject {
                 // Don't add an email with no known paths - it may
                 // have been removed after being listed for adding.
                 conversation = add_email(
-                    email, base_folder, known_paths,
-                    out added_conversation
+                    email, known_paths, out added_conversation
                 );
             }
 
@@ -235,7 +246,6 @@ private class Geary.App.ConversationSet : BaseObject {
      * was created, else it is set to `false`.
      */
     private Conversation? add_email(Geary.Email email,
-                                    Folder base_folder,
                                     Gee.Collection<FolderPath>? known_paths,
                                     out bool added_conversation) {
         added_conversation = false;
@@ -255,7 +265,7 @@ private class Geary.App.ConversationSet : BaseObject {
             if (conversation == null) {
                 // Not in or related to any existing conversations, so
                 // create one
-                conversation = new Conversation(base_folder);
+                conversation = new Conversation(this.base_folder);
                 _conversations.add(conversation);
                 added_conversation = true;
             }
diff --git a/test/engine/app/app-conversation-set-test.vala b/test/engine/app/app-conversation-set-test.vala
index a662e9e3..bae79bc3 100644
--- a/test/engine/app/app-conversation-set-test.vala
+++ b/test/engine/app/app-conversation-set-test.vala
@@ -35,7 +35,7 @@ class Geary.App.ConversationSetTest : TestCase {
             SpecialFolderType.NONE,
             null
         );
-        this.test = new ConversationSet();
+        this.test = new ConversationSet(this.base_folder);
     }
 
     public override void tear_down() {
@@ -62,7 +62,7 @@ class Geary.App.ConversationSetTest : TestCase {
         Gee.Collection<Conversation>? removed = null;
 
         this.test.add_all_emails(
-            emails, email_paths, this.base_folder,
+            emails, email_paths,
             out added, out appended, out removed
         );
 
@@ -108,8 +108,7 @@ class Geary.App.ConversationSetTest : TestCase {
         Gee.MultiMap<Conversation,Email>? appended = null;
         Gee.Collection<Conversation>? removed = null;
         this.test.add_all_emails(
-            emails, email_paths, this.base_folder,
-            out added, out appended, out removed
+            emails, email_paths, out added, out appended, out removed
         );
 
         assert(this.test.size == 1);
@@ -127,8 +126,7 @@ class Geary.App.ConversationSetTest : TestCase {
         appended = null;
         removed = null;
         this.test.add_all_emails(
-            emails, email_paths, this.base_folder,
-            out added, out appended, out removed
+            emails, email_paths, out added, out appended, out removed
         );
 
         assert(this.test.size == 1);
@@ -158,8 +156,7 @@ class Geary.App.ConversationSetTest : TestCase {
         Gee.MultiMap<Conversation,Email>? appended = null;
         Gee.Collection<Conversation>? removed = null;
         this.test.add_all_emails(
-            emails, email_paths, this.base_folder,
-            out added, out appended, out removed
+            emails, email_paths, out added, out appended, out removed
         );
 
         assert(this.test.size == 1);
@@ -188,8 +185,7 @@ class Geary.App.ConversationSetTest : TestCase {
         appended = null;
         removed = null;
         this.test.add_all_emails(
-            emails, email_paths, this.base_folder,
-            out added, out appended, out removed
+            emails, email_paths, out added, out appended, out removed
         );
 
         assert(this.test.size == 1);
@@ -228,8 +224,7 @@ class Geary.App.ConversationSetTest : TestCase {
         Gee.MultiMap<Conversation,Email>? appended = null;
         Gee.Collection<Conversation>? removed = null;
         this.test.add_all_emails(
-            emails, email_paths, this.base_folder,
-            out added, out appended, out removed
+            emails, email_paths, out added, out appended, out removed
         );
 
         assert(this.test.size == 1);
@@ -278,8 +273,7 @@ class Geary.App.ConversationSetTest : TestCase {
         Gee.MultiMap<Conversation,Email>? appended = null;
         Gee.Collection<Conversation>? removed = null;
         this.test.add_all_emails(
-            emails, email_paths, this.base_folder,
-            out added, out appended, out removed
+            emails, email_paths, out added, out appended, out removed
         );
 
         assert(this.test.size == 1);
@@ -332,8 +326,7 @@ class Geary.App.ConversationSetTest : TestCase {
         Gee.MultiMap<Conversation,Email>? appended = null;
         Gee.Collection<Conversation>? removed = null;
         this.test.add_all_emails(
-            emails, email_paths, this.base_folder,
-            out added, out appended, out removed
+            emails, email_paths, out added, out appended, out removed
         );
 
         assert(this.test.size == 1);
@@ -361,8 +354,7 @@ class Geary.App.ConversationSetTest : TestCase {
         Gee.MultiMap<Conversation,Email>? appended = null;
         Gee.Collection<Conversation>? removed = null;
         this.test.add_all_emails(
-            emails, email_paths, this.base_folder,
-            out added, out appended, out removed
+            emails, email_paths, out added, out appended, out removed
         );
 
         assert(this.test.size == 1);
@@ -499,8 +491,7 @@ class Geary.App.ConversationSetTest : TestCase {
         Gee.MultiMap<Conversation,Email>? appended = null;
         Gee.Collection<Conversation>? removed = null;
         this.test.add_all_emails(
-            emails, email_paths, this.base_folder,
-            out added, out appended, out removed
+            emails, email_paths, out added, out appended, out removed
         );
     }
 


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