[geary/wip/289-folder-not-fully-populated] Ensure ImapDb.Folder updates email total when marking removed
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/289-folder-not-fully-populated] Ensure ImapDb.Folder updates email total when marking removed
- Date: Thu, 4 Apr 2019 08:39:22 +0000 (UTC)
commit d6ca47bacc9adf01271aff0766d28892496c1a74
Author: Michael Gratton <mike vee net>
Date: Thu Apr 4 19:35:43 2019 +1100
Ensure ImapDb.Folder updates email total when marking removed
Updates the total email count as well as the unread email count when
adding or removing the removed frag from messages.
This prevents the ConversationMonitor freaking out between removing a
message from the base folder and the IMAP server notifting that the
change has occurred.
src/engine/imap-db/imap-db-folder.vala | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/engine/imap-db/imap-db-folder.vala b/src/engine/imap-db/imap-db-folder.vala
index 24b22827..605183a6 100644
--- a/src/engine/imap-db/imap-db-folder.vala
+++ b/src/engine/imap-db/imap-db-folder.vala
@@ -1057,6 +1057,7 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
public async Gee.Set<ImapDB.EmailIdentifier>? mark_removed_async(
Gee.Collection<ImapDB.EmailIdentifier>? ids, bool mark_removed, Cancellable? cancellable)
throws Error {
+ int total_changed = 0;
int unread_count = 0;
Gee.Set<ImapDB.EmailIdentifier> removed_ids = new Gee.HashSet<ImapDB.EmailIdentifier>();
yield db.exec_transaction_async(Db.TransactionType.RW, (cx) => {
@@ -1069,6 +1070,7 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
if (locs == null || locs.size == 0)
return Db.TransactionOutcome.DONE;
+ total_changed = locs.size;
unread_count = do_get_unread_count_for_ids(cx, ids, cancellable);
Gee.HashSet<Imap.UID> uids = new Gee.HashSet<Imap.UID>();
@@ -1077,14 +1079,26 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
removed_ids.add(location.email_id);
}
- if (uids.size > 0)
- do_mark_unmark_removed(cx, uids, mark_removed, cancellable);
-
+ do_mark_unmark_removed(cx, uids, mark_removed, cancellable);
do_add_to_unread_count(cx, -unread_count, cancellable);
return Db.TransactionOutcome.DONE;
}, cancellable);
+
+ // Update the folder properties so client sees the changes
+ // right away
+
+ // Email total
+ if (mark_removed) {
+ total_changed = -total_changed;
+ }
+ int total = this.properties.select_examine_messages + total_changed;
+ if (total >= 0) {
+ this.properties.set_select_examine_message_count(total);
+ }
+
+ // Unread total
if (unread_count > 0)
properties.set_status_unseen(properties.email_unread - unread_count);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]