[geary/mjog/account-command-stacks: 26/27] Merge Controller.move_conversations and move_messages impls



commit 758142d71ce34e61f35f3632396b0160c7d04324
Author: Michael Gratton <mike vee net>
Date:   Thu Oct 24 12:50:52 2019 +1100

    Merge Controller.move_conversations and move_messages impls
    
    Use the same implementation for moving conversations and messages so
    that marking messages is notified in the same way as marking
    conversations. Athough in the case of the latter, only a subset of the
    messages in a conversation may get marked, it makes the UI notification
    UI present more consistently.

 src/client/application/application-controller.vala | 49 +++++++---------------
 src/client/components/main-window.vala             |  4 +-
 .../conversation-viewer/conversation-list-box.vala | 24 ++++++++---
 3 files changed, 38 insertions(+), 39 deletions(-)
---
diff --git a/src/client/application/application-controller.vala 
b/src/client/application/application-controller.vala
index 34889f0f..d6295660 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -554,31 +554,13 @@ public class Application.Controller : Geary.BaseObject {
             }
         }
 
-        AccountContext? context = this.accounts.get(target.information);
-        if (context != null) {
-            yield context.commands.execute(
-                new MarkEmailCommand(
-                    context.emails,
-                    messages,
-                    do_add ? flags : null,
-                    do_add ? null : flags,
-                    /// Translators: Label for in-app undo notification
-                    ngettext(
-                        "Conversation marked",
-                        "Conversations marked",
-                        selected.size
-                    ),
-                    /// Translators: Label for in-app undo notification
-                    ngettext(
-                        "Conversation un-marked",
-                        "Conversations un-marked",
-                        selected.size
-                    )
-
-                ),
-                context.cancellable
-            );
-        }
+        yield mark_messages(
+            target,
+            conversations,
+            messages,
+            do_add ? flags : null,
+            do_add ? null : flags
+        );
     }
 
     /**
@@ -590,6 +572,7 @@ public class Application.Controller : Geary.BaseObject {
      * case, use {@link mark_conversations}.
      */
     public async void mark_messages(Geary.Account target,
+                                    Gee.Collection<Geary.App.Conversation> conversations,
                                     Gee.Collection<Geary.EmailIdentifier> messages,
                                     Geary.EmailFlags? to_add,
                                     Geary.EmailFlags? to_remove)
@@ -602,17 +585,17 @@ public class Application.Controller : Geary.BaseObject {
                     messages,
                     to_add,
                     to_remove,
-                    /// Translators: Label for in-app undo notification
+                    /// Translators: Label for in-app notification
                     ngettext(
-                        "Message marked",
-                        "Messages marked",
-                        messages.size
+                        "Conversation marked",
+                        "Conversations marked",
+                        conversations.size
                     ),
-                    /// Translators: Label for in-app undo notification
+                    /// Translators: Label for in-app notification
                     ngettext(
-                        "Message un-marked",
-                        "Messages un-marked",
-                        messages.size
+                        "Conversation un-marked",
+                        "Conversations un-marked",
+                        conversations.size
                     )
                 ),
                 context.cancellable
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 9f0727f6..1cd69452 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -1782,13 +1782,15 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
 
     // Individual message view action callbacks
 
-    private void on_mark_messages(Gee.Collection<Geary.EmailIdentifier> messages,
+    private void on_mark_messages(Geary.App.Conversation conversation,
+                                  Gee.Collection<Geary.EmailIdentifier> messages,
                                   Geary.EmailFlags? to_add,
                                   Geary.EmailFlags? to_remove) {
         Geary.Account? target = this.selected_account;
         if (target != null) {
             this.application.controller.mark_messages.begin(
                 target,
+                Geary.Collection.single(conversation),
                 messages,
                 to_add,
                 to_remove,
diff --git a/src/client/conversation-viewer/conversation-list-box.vala 
b/src/client/conversation-viewer/conversation-list-box.vala
index 39333946..e12528d4 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -543,8 +543,12 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
     public signal void email_removed(ConversationEmail email);
 
     /** Fired when the user updates the flags for a set of emails. */
-    public signal void mark_emails(Gee.Collection<Geary.EmailIdentifier> emails,
-        Geary.EmailFlags? flags_to_add, Geary.EmailFlags? flags_to_remove);
+    public signal void mark_emails(
+        Geary.App.Conversation conversation,
+        Gee.Collection<Geary.EmailIdentifier> emails,
+        Geary.EmailFlags? flags_to_add,
+        Geary.EmailFlags? flags_to_remove
+    );
 
 
     /**
@@ -1046,7 +1050,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
         if (email_ids.size > 0) {
             Geary.EmailFlags flags = new Geary.EmailFlags();
             flags.add(Geary.EmailFlags.UNREAD);
-            mark_emails(email_ids, null, flags);
+            mark_emails(this.conversation, email_ids, null, flags);
         }
     }
 
@@ -1137,7 +1141,12 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
         Gee.Collection<Geary.EmailIdentifier> ids =
             new Gee.LinkedList<Geary.EmailIdentifier>();
         ids.add(view.email.id);
-        mark_emails(ids, flag_to_flags(to_add), flag_to_flags(to_remove));
+        mark_emails(
+            this.conversation,
+            ids,
+            flag_to_flags(to_add),
+            flag_to_flags(to_remove)
+        );
     }
 
     private void on_mark_email_from_here(ConversationEmail view,
@@ -1156,7 +1165,12 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
                     }
                 }
             });
-        mark_emails(ids, flag_to_flags(to_add), flag_to_flags(to_remove));
+        mark_emails(
+            this.conversation,
+            ids,
+            flag_to_flags(to_add),
+            flag_to_flags(to_remove)
+        );
     }
 
     private void on_message_body_state_notify(GLib.Object obj,


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