[geary] Synchronize with Sent Mail immed. after sending one: Refs bug #714450



commit c0607fccccf71af9a0a2e67fcd65ed7669def9da
Author: Jim Nelson <jim yorba org>
Date:   Wed Jun 11 17:18:35 2014 -0700

    Synchronize with Sent Mail immed. after sending one: Refs bug #714450
    
    This doesn't completely solve bug #714450 but it does display a reply
    or forwarded message more quickly in a conversation (rather than wait
    for the Account object to signal that a Folder's contents has changed,
    which is polled and may take minutes to notice).
    
    This also slightly rearranges the priority order for background
    synchronization, recognizing that some Folders (Drafts, Sent Mail) are
    as active as All Mail but quicker to synchronize with (i.e. don't wait
    for All Mail to complete synchronization before checking those).

 .../imap-engine-account-synchronizer.vala          |   27 ++++++++++++++-----
 1 files changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-account-synchronizer.vala 
b/src/engine/imap-engine/imap-engine-account-synchronizer.vala
index 8d53d50..071cc72 100644
--- a/src/engine/imap-engine/imap-engine-account-synchronizer.vala
+++ b/src/engine/imap-engine/imap-engine-account-synchronizer.vala
@@ -6,7 +6,7 @@
 
 private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
     private const int FETCH_DATE_RECEIVED_CHUNK_COUNT = 25;
-    private const int SYNC_DELAY_SEC = 15;
+    private const int SYNC_DELAY_SEC = 2;
     
     public GenericAccount account { get; private set; }
     
@@ -30,6 +30,7 @@ private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
         account.closed.connect(on_account_closed);
         account.folders_available_unavailable.connect(on_folders_available_unavailable);
         account.folders_contents_altered.connect(on_folders_contents_altered);
+        account.email_sent.connect(on_email_sent);
     }
     
     ~AccountSynchronizer() {
@@ -37,6 +38,7 @@ private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
         account.closed.disconnect(on_account_closed);
         account.folders_available_unavailable.disconnect(on_folders_available_unavailable);
         account.folders_contents_altered.disconnect(on_folders_contents_altered);
+        account.email_sent.disconnect(on_email_sent);
     }
     
     public async void stop_async() {
@@ -109,6 +111,16 @@ private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
         delayed_send_all(altered, false);
     }
     
+    private void on_email_sent() {
+        try {
+            Folder? sent_mail = account.get_special_folder(SpecialFolderType.SENT);
+            if (sent_mail != null)
+                send_all(iterate<Folder>(sent_mail).to_array_list(), false);
+        } catch (Error err) {
+            debug("Unable to retrieve Sent Mail from %s: %s", account.to_string(), err.message);
+        }
+    }
+    
     private void delayed_send_all(Gee.Collection<Folder> folders, bool reason_available) {
         Timeout.add_seconds(SYNC_DELAY_SEC, () => {
             // remove any unavailable folders
@@ -183,19 +195,20 @@ private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
             case SpecialFolderType.INBOX:
                 return -60;
             
-            case SpecialFolderType.ALL_MAIL:
+            case SpecialFolderType.SENT:
                 return -50;
             
-            case SpecialFolderType.SENT:
+            case SpecialFolderType.DRAFTS:
                 return -40;
             
-            case SpecialFolderType.FLAGGED:
+            case SpecialFolderType.ALL_MAIL:
+            case SpecialFolderType.ARCHIVE:
                 return -30;
             
-            case SpecialFolderType.IMPORTANT:
+            case SpecialFolderType.FLAGGED:
                 return -20;
             
-            case SpecialFolderType.DRAFTS:
+            case SpecialFolderType.IMPORTANT:
                 return -10;
             
             case SpecialFolderType.SPAM:
@@ -359,7 +372,7 @@ private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
                     break;
                 }
                 
-                current_epoch = current_epoch.add_months(-3);
+                current_epoch = current_epoch.add_months(-1);
                 
                 // if past max_epoch, then just pull in everything and be done with it
                 if (current_epoch.compare(max_epoch) < 0) {


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