From 48b11d7c0aefcb02ce996f1ef8f5d50f107574b7 Mon Sep 17 00:00:00 2001 From: Leonhard Date: Mon, 31 Jul 2023 16:25:39 +0200 Subject: [PATCH 1/3] Refresh folder when selecting --- src/ConversationList/ConversationList.vala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ConversationList/ConversationList.vala b/src/ConversationList/ConversationList.vala index 9536267c6..0e5c3eb28 100644 --- a/src/ConversationList/ConversationList.vala +++ b/src/ConversationList/ConversationList.vala @@ -311,6 +311,8 @@ public class Mail.ConversationList : Gtk.Box { } list_store.items_changed (0, 0, list_store.get_n_items ()); + + refresh_folder.begin (cancellable); } public async void refresh_folder (GLib.Cancellable? cancellable = null) { From ee5669acd42e859f4fb7dc7408713af6113f259f Mon Sep 17 00:00:00 2001 From: Leonhard Date: Mon, 31 Jul 2023 16:43:19 +0200 Subject: [PATCH 2/3] Fix crashes --- src/ConversationList/ConversationList.vala | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/ConversationList/ConversationList.vala b/src/ConversationList/ConversationList.vala index 0e5c3eb28..54241cff6 100644 --- a/src/ConversationList/ConversationList.vala +++ b/src/ConversationList/ConversationList.vala @@ -247,6 +247,9 @@ public class Mail.ConversationList : Gtk.Box { cancellable.cancel (); } + var cancellable = new GLib.Cancellable (); + this.cancellable = cancellable; + conversation_focused (null); conversation_selected (null); @@ -261,8 +264,6 @@ public class Mail.ConversationList : Gtk.Box { list_store.remove_all (); list_store.items_changed (0, previous_items, 0); - cancellable = new GLib.Cancellable (); - lock (this.folder_full_name_per_account) { foreach (var folder_full_name_entry in this.folder_full_name_per_account) { var current_account = folder_full_name_entry.key; @@ -311,21 +312,28 @@ public class Mail.ConversationList : Gtk.Box { } list_store.items_changed (0, 0, list_store.get_n_items ()); - refresh_folder.begin (cancellable); } public async void refresh_folder (GLib.Cancellable? cancellable = null) { + if (cancellable != null && cancellable.is_cancelled ()) { + return; + } + refresh_stack.set_visible_child_name ("spinner"); lock (folders) { foreach (var folder in folders.values) { try { yield folder.refresh_info (GLib.Priority.DEFAULT, cancellable); } catch (Error e) { - warning ("Error fetching messages for '%s' from '%s': %s", - folder.display_name, - folder.parent_store.display_name, - e.message); + if (e is IOError.CANCELLED) { + break; + } else { + warning ("Error fetching messages for '%s' from '%s': %s", + folder.display_name, + folder.parent_store.display_name, + e.message); + } } } } From 65267b7dee970624c7bd956d394a7aff1236c7ea Mon Sep 17 00:00:00 2001 From: Leonhard Date: Tue, 1 Aug 2023 14:31:10 +0200 Subject: [PATCH 3/3] Simplify --- src/ConversationList/ConversationList.vala | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/ConversationList/ConversationList.vala b/src/ConversationList/ConversationList.vala index 54241cff6..ede996623 100644 --- a/src/ConversationList/ConversationList.vala +++ b/src/ConversationList/ConversationList.vala @@ -325,15 +325,13 @@ public class Mail.ConversationList : Gtk.Box { foreach (var folder in folders.values) { try { yield folder.refresh_info (GLib.Priority.DEFAULT, cancellable); - } catch (Error e) { - if (e is IOError.CANCELLED) { + } catch (IOError.CANCELLED e) { break; - } else { - warning ("Error fetching messages for '%s' from '%s': %s", - folder.display_name, - folder.parent_store.display_name, - e.message); - } + } catch (Error e) { + warning ("Error fetching messages for '%s' from '%s': %s", + folder.display_name, + folder.parent_store.display_name, + e.message); } } }