[geary/wip/create-folders-713492: 19/26] Use required folder for spam



commit fa9342c915496aeeabf696c315dc0381dde12504
Author: Charles Lindsay <chaz yorba org>
Date:   Thu Feb 6 12:11:56 2014 -0800

    Use required folder for spam

 src/client/application/geary-controller.vala |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 6b61dea..6f8b5e0 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -1421,15 +1421,7 @@ public class GearyController : Geary.BaseObject {
         actions.get_action(ACTION_MARK_AS_STARRED).set_visible(unstarred_selected);
         actions.get_action(ACTION_MARK_AS_UNSTARRED).set_visible(starred_selected);
         
-        Geary.Folder? spam_folder = null;
-        try {
-            spam_folder = current_account.get_special_folder(Geary.SpecialFolderType.SPAM);
-        } catch (Error e) {
-            debug("Could not locate special spam folder: %s", e.message);
-        }
-        
-        if (spam_folder != null &&
-            current_folder.special_folder_type != Geary.SpecialFolderType.DRAFTS &&
+        if (current_folder.special_folder_type != Geary.SpecialFolderType.DRAFTS &&
             current_folder.special_folder_type != Geary.SpecialFolderType.OUTBOX) {
             if (current_folder.special_folder_type == Geary.SpecialFolderType.SPAM) {
                 // We're in the spam folder.
@@ -1441,7 +1433,7 @@ public class GearyController : Geary.BaseObject {
                 actions.get_action(ACTION_MARK_AS_SPAM).label = MARK_AS_SPAM_LABEL;
             }
         } else {
-            // No Spam folder, or we're in Drafts/Outbox, so gray-out the option.
+            // We're in Drafts/Outbox, so gray-out the option.
             actions.get_action(ACTION_MARK_AS_SPAM).sensitive = false;
             actions.get_action(ACTION_MARK_AS_SPAM).label = MARK_AS_SPAM_LABEL;
         }
@@ -1526,12 +1518,13 @@ public class GearyController : Geary.BaseObject {
         mark_email(get_selected_email_ids(false), null, flags);
     }
     
-    private void on_mark_as_spam() {
+    private async void mark_as_spam_async(Cancellable? cancellable) {
         Geary.Folder? destination_folder = null;
         if (current_folder.special_folder_type != Geary.SpecialFolderType.SPAM) {
             // Move to spam folder.
             try {
-                destination_folder = current_account.get_special_folder(Geary.SpecialFolderType.SPAM);
+                destination_folder = yield current_account.get_required_special_folder_async(
+                    Geary.SpecialFolderType.SPAM, cancellable);
             } catch (Error e) {
                 debug("Error getting spam folder: %s", e.message);
             }
@@ -1548,6 +1541,10 @@ public class GearyController : Geary.BaseObject {
             on_move_conversation(destination_folder);
     }
     
+    private void on_mark_as_spam() {
+        mark_as_spam_async.begin(null);
+    }
+    
     private void copy_email(Gee.Collection<Geary.EmailIdentifier> ids,
         Geary.FolderPath destination) {
         if (ids.size > 0) {


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