Merge branch 'wip/712902-empty-gmail-folder' into 'master'

Do not add childless, non openable folders entry in sidemenu

See merge request GNOME/geary!84
This commit is contained in:
Michael Gratton 2019-01-15 23:40:26 +00:00
commit 3a932cf5fc

View file

@ -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.parent == folder.path)
return true;
}
return false;
}
private void on_account_available(Geary.AccountInformation info) {
Geary.Account? account = null;
try {