[geary/mjog/email-templates: 55/72] Application.FolderStoreFactory: Improve folder signal impl
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/email-templates: 55/72] Application.FolderStoreFactory: Improve folder signal impl
- Date: Mon, 20 Apr 2020 13:54:47 +0000 (UTC)
commit 97b807f0b41435d350e90e2bd256d082f7d86616
Author: Michael Gratton <mike vee net>
Date: Fri Apr 17 15:26:03 2020 +1000
Application.FolderStoreFactory: Improve folder signal impl
Only signal folders available/unavailable if non-empty when adding or
removing accounts, avoid producing two collections when signalling, and
fix removing folders from the store before signalling that they have
been removed.
.../application-folder-store-factory.vala | 36 +++++++++++++---------
1 file changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/src/client/application/application-folder-store-factory.vala
b/src/client/application/application-folder-store-factory.vala
index c8aa2290..262205ff 100644
--- a/src/client/application/application-folder-store-factory.vala
+++ b/src/client/application/application-folder-store-factory.vala
@@ -195,14 +195,20 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
added.folders_available.connect(on_folders_available);
added.folders_unavailable.connect(on_folders_unavailable);
added.account.folders_use_changed.connect(on_folders_use_changed);
- add_folders(added, added.get_folders());
+ var folders = added.get_folders();
+ if (!folders.is_empty) {
+ add_folders(added, folders);
+ }
}
internal void remove_account(AccountContext removed) {
removed.folders_available.disconnect(on_folders_available);
removed.folders_unavailable.disconnect(on_folders_unavailable);
removed.account.folders_use_changed.disconnect(on_folders_use_changed);
- remove_folders(removed, removed.get_folders());
+ var folders = removed.get_folders();
+ if (!folders.is_empty) {
+ remove_folders(removed, folders);
+ }
}
internal void main_window_added(MainWindow added) {
@@ -217,11 +223,11 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
new FolderImpl(context, this.accounts.get(account))
);
}
- var folder_impls = to_plugin_folders(
- Geary.traverse(to_add)
- .map<Geary.Folder>((context => context.folder))
- .to_linked_list()
- ).read_only_view;
+ var folder_impls = Geary.traverse(
+ to_add
+ ).map<FolderImpl>(
+ (context => this.folders.get(context.folder))
+ ).to_linked_list().read_only_view;
foreach (FolderStoreImpl store in this.stores) {
store.folders_available(folder_impls);
}
@@ -229,17 +235,17 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
private void remove_folders(AccountContext account,
Gee.Collection<FolderContext> to_remove) {
- foreach (var context in to_remove) {
- this.folders.unset(context.folder);
- }
- var folder_impls = to_plugin_folders(
- Geary.traverse(to_remove)
- .map<Geary.Folder>((context => context.folder))
- .to_linked_list()
- ).read_only_view;
+ var folder_impls = Geary.traverse(
+ to_remove
+ ).map<FolderImpl>(
+ (context => this.folders.get(context.folder))
+ ).to_linked_list().read_only_view;
foreach (FolderStoreImpl store in this.stores) {
store.folders_unavailable(folder_impls);
}
+ foreach (var context in to_remove) {
+ this.folders.unset(context.folder);
+ }
}
private Gee.Collection<FolderImpl> to_plugin_folders(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]