[geary/wip/unread-status-714865: 10/10] Only fetch unseen count for existing folders
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/unread-status-714865: 10/10] Only fetch unseen count for existing folders
- Date: Fri, 21 Feb 2014 01:29:46 +0000 (UTC)
commit d5889f203b7fa72ac5985217f55c8c5c4bef5436
Author: Charles Lindsay <chaz yorba org>
Date: Thu Feb 20 17:27:12 2014 -0800
Only fetch unseen count for existing folders
.../imap-engine/imap-engine-generic-account.vala | 17 ++++++++++-------
.../imap-engine/imap-engine-minimal-folder.vala | 2 +-
src/engine/imap/api/imap-account.vala | 8 ++++++--
3 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 3b88595..8d05d2f 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -321,12 +321,15 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
debug("Refreshing unseen counts for %s", folder.to_string());
- int unseen_count = yield remote.fetch_unseen_count_async(folder.path, cancellable);
+ bool folder_created;
+ Imap.Folder remote_folder = yield remote.fetch_folder_async(folder.path,
+ out folder_created, cancellable);
- Imap.Folder remote_folder = yield remote.fetch_folder_async(folder.path, cancellable);
- // TODO: nothing to refresh if that fetch just hit the network.
- remote_folder.properties.set_status_unseen(unseen_count);
- yield local.update_folder_status_async(remote_folder, false, cancellable);
+ if (!folder_created) {
+ int unseen_count = yield remote.fetch_unseen_count_async(folder.path, cancellable);
+ remote_folder.properties.set_status_unseen(unseen_count);
+ yield local.update_folder_status_async(remote_folder, false, cancellable);
+ }
in_refresh_unseen.remove(folder);
}
@@ -490,7 +493,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
continue;
Imap.Folder remote_folder = (Imap.Folder) yield remote.fetch_folder_async(folder,
- cancellable);
+ null, cancellable);
yield local.clone_folder_async(remote_folder, cancellable);
}
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index f1e6297..8d77123 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -515,7 +515,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
try {
debug("Fetching information for remote folder %s", to_string());
Imap.Folder folder = yield remote.fetch_folder_async(local_folder.get_path(),
- cancellable);
+ null, cancellable);
debug("Opening remote folder %s", folder.to_string());
yield folder.open_async(cancellable);
diff --git a/src/engine/imap/api/imap-account.vala b/src/engine/imap/api/imap-account.vala
index d8940c1..c04d314 100644
--- a/src/engine/imap/api/imap-account.vala
+++ b/src/engine/imap/api/imap-account.vala
@@ -164,13 +164,17 @@ private class Geary.Imap.Account : BaseObject {
}
}
- public async Imap.Folder fetch_folder_async(FolderPath path, Cancellable? cancellable)
- throws Error {
+ public async Imap.Folder fetch_folder_async(FolderPath path, out bool created,
+ Cancellable? cancellable) throws Error {
check_open();
+ created = false;
+
if (folders.has_key(path))
return folders.get(path);
+ created = true;
+
// if not in map, use list_children_async to add it (if it exists)
if (!path_to_mailbox.has_key(path)) {
debug("Listing children to find %s", path.to_string());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]