[geary/mjog/invert-folder-class-hierarchy: 59/72] ConversationListStore: Minor code cleanup.




commit 505fa858723d115c1f4faea8c3ddf329347f7bca
Author: Michael Gratton <mike vee net>
Date:   Sun Feb 28 19:49:49 2021 +1100

    ConversationListStore: Minor code cleanup.
    
    Make `do_refresh_previews_async` a bit cleaner and less work, fix
    nullability issues with `do_get_previews_async`.

 .../conversation-list/conversation-list-store.vala | 37 +++++++++-------------
 1 file changed, 15 insertions(+), 22 deletions(-)
---
diff --git a/src/client/conversation-list/conversation-list-store.vala 
b/src/client/conversation-list/conversation-list-store.vala
index b30140586..3014b1d7d 100644
--- a/src/client/conversation-list/conversation-list-store.vala
+++ b/src/client/conversation-list/conversation-list-store.vala
@@ -165,9 +165,7 @@ public class ConversationListStore : Gtk.ListStore {
         }
 
         preview_monitor.notify_start();
-
         yield do_refresh_previews_async(conversation_monitor);
-
         preview_monitor.notify_finish();
 
         try {
@@ -182,30 +180,25 @@ public class ConversationListStore : Gtk.ListStore {
         if (conversation_monitor == null || !this.config.display_preview)
             return;
 
-        Gee.Set<Geary.EmailIdentifier> needing_previews =
-            get_emails_needing_previews();
-
-        var emails = new Gee.ArrayList<Geary.Email>();
-        if (needing_previews.size > 0) {
-            var with_previews = yield do_get_previews_async(needing_previews);
-            if (with_previews != null) {
-                emails.add_all(with_previews);
-            }
-        }
-        foreach (Geary.Email email in emails) {
-            Geary.App.Conversation? conversation = conversation_monitor.get_by_email_identifier(email.id);
-            // The conversation can be null if e.g. a search is
-            // changing quickly and the original has evaporated
-            // already.
-            if (conversation != null) {
-                set_preview_for_conversation(conversation, email);
+        var with_previews = yield do_get_previews_async(get_emails_needing_previews());
+        if (with_previews != null) {
+            foreach (var email in with_previews) {
+                Geary.App.Conversation? conversation =
+                    conversation_monitor.get_by_email_identifier(email.id);
+                // The conversation can be null if e.g. a search is
+                // changing quickly and the original has evaporated
+                // already.
+                if (conversation != null) {
+                    set_preview_for_conversation(conversation, email);
+                }
             }
         }
     }
 
-    private async Gee.Collection<Geary.Email> do_get_previews_async(
-        Gee.Collection<Geary.EmailIdentifier> emails_needing_previews) {
-        Gee.Collection<Geary.Email> emails = null;
+    private async Gee.Collection<Geary.Email>? do_get_previews_async(
+        Gee.Collection<Geary.EmailIdentifier> ids
+    ) {
+        Gee.Collection<Geary.Email>? emails = null;
         try {
             emails = yield email_store.get_multiple_email_by_id(
                 emails_needing_previews,


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