[geary/wip/712902-empty-gmail-folder] Do not add non openable folders entry in sidemenu. Bug 712902



commit 804a76820abc4a8d4ee5b9ae2cddf6b074f0ad2a
Author: Gautier Pelloux-Prayer <gautier+git damsy net>
Date:   Thu Mar 2 12:35:39 2017 +0100

    Do not add non openable folders entry in sidemenu. Bug 712902

 src/client/application/geary-controller.vala | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 476ba537..8a498cde 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -1330,6 +1330,10 @@ public class GearyController : Geary.BaseObject {
 
         if (available != null && available.size > 0) {
             foreach (Geary.Folder folder in available) {
+                if (!should_add_folder(available, folder)) {
+                    continue;
+                }
+
                 main_window.folder_list.add_folder(folder);
                 if (folder.account == current_account) {
                     if (!main_window.main_toolbar.copy_folder_menu.has_folder(folder))
@@ -2764,6 +2768,23 @@ public class GearyController : Geary.BaseObject {
         return context != null ? context.store : null;
     }
 
+    private bool should_add_folder(Gee.List<Geary.Folder>? all, Geary.Folder folder) {
+        // if folder is openable, add it
+        if (folder.properties.is_openable != Geary.Trillian.FALSE)
+            return true;
+        else if (folder.properties.has_children == Geary.Trillian.FALSE)
+            return false;
+
+        // if folder contains children, we must ensure that there is at least one of the same type
+        Geary.SpecialFolderType type = folder.special_folder_type;
+        foreach (Geary.Folder other in all) {
+            if (other.special_folder_type == type && other.path.get_parent() == folder.path)
+                return true;
+        }
+
+        return false;
+    }
+
     private void on_account_available(Geary.AccountInformation info) {
         Geary.Account? account = null;
         try {


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