From 12a9fa2272590ca7827649aed3693f229df9200c Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 31 Mar 2020 18:58:29 +0200 Subject: [PATCH] Optimize fetching subscribed folders --- app/src/main/java/eu/faircode/email/Core.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 269d92a702..c4b8c7aab2 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1280,6 +1280,15 @@ class Core { long start = new Date().getTime(); Folder[] ifolders = defaultFolder.list("*"); + List subscription = new ArrayList<>(); + try { + Folder[] isubscribed = defaultFolder.listSubscribed("*"); + for (Folder ifolder : isubscribed) + subscription.add(ifolder.getFullName()); + } catch (MessagingException ex) { + Log.e(account.name, ex); + } + long duration = new Date().getTime() - start; Log.i("Remote folder count=" + ifolders.length + @@ -1292,7 +1301,7 @@ class Core { String fullName = ifolder.getFullName(); String[] attrs = ((IMAPFolder) ifolder).getAttributes(); String type = EntityFolder.getType(attrs, fullName, false); - boolean subscribed = ifolder.isSubscribed(); + boolean subscribed = subscription.contains(fullName); boolean selectable = true; boolean inferiors = true;