diff options
Diffstat (limited to 'mail/mail-folder-cache.c')
-rw-r--r-- | mail/mail-folder-cache.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index a9726ea0db..094a046c38 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -301,7 +301,8 @@ folder_changed_cb (CamelFolder *folder, CamelFolderChangeInfo *changes, MailFolderCache *self) { - static time_t last_newmail = 0; + static GHashTable *last_newmail_per_folder = NULL; + time_t latest_received; CamelFolder *local_drafts; CamelFolder *local_outbox; CamelFolder *local_sent; @@ -318,6 +319,12 @@ folder_changed_cb (CamelFolder *folder, full_name = camel_folder_get_full_name (folder); parent_store = camel_folder_get_parent_store (folder); + if (!last_newmail_per_folder) + last_newmail_per_folder = g_hash_table_new (g_direct_hash, g_direct_equal); + + /* it's fine to hash them by folder pointer here */ + latest_received = GPOINTER_TO_INT (g_hash_table_lookup (last_newmail_per_folder, folder)); + local_drafts = e_mail_local_get_folder (E_MAIL_FOLDER_DRAFTS); local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX); local_sent = e_mail_local_get_folder (E_MAIL_FOLDER_SENT); @@ -336,7 +343,8 @@ folder_changed_cb (CamelFolder *folder, if (((flags & CAMEL_MESSAGE_SEEN) == 0) && ((flags & CAMEL_MESSAGE_JUNK) == 0) && ((flags & CAMEL_MESSAGE_DELETED) == 0) && - (camel_message_info_date_received (info) > last_newmail)) { + (camel_message_info_date_received (info) > latest_received)) { + latest_received = camel_message_info_date_received (info); new++; if (new == 1) { uid = g_strdup (camel_message_info_uid (info)); @@ -357,8 +365,8 @@ folder_changed_cb (CamelFolder *folder, } } - if (new > 0 || !last_newmail) - time (&last_newmail); + if (new > 0) + g_hash_table_insert (last_newmail_per_folder, folder, GINT_TO_POINTER (latest_received)); g_mutex_lock (self->priv->stores_mutex); if (self->priv->stores != NULL |