[geary] Fix convo viewer sometimes scrolling past the first unread message.



commit 3b33f587a9df5dc5f69271f3bab06fba0b516cdc
Author: Michael James Gratton <mike vee net>
Date:   Sat Oct 22 09:02:20 2016 +1100

    Fix convo viewer sometimes scrolling past the first unread message.
    
    ConversationListBox was scrolling to the first expanded row in insertion
    order, not necessarily the first in display order. This fixes that.
    
    * src/client/conversation-viewer/conversation-list-box.vala
      (ConversationListBox::load_conversation): Compare expanded rows by sort
      order when inserting them, rather than by just taking the first one
      encountered. Delay loading it first until all have been inserted, so we
      know we are actually loading the first one first.

 .../conversation-viewer/conversation-list-box.vala |   24 ++++++-------------
 1 files changed, 8 insertions(+), 16 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-list-box.vala 
b/src/client/conversation-viewer/conversation-list-box.vala
index f36fd74..ac15caf 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -326,8 +326,6 @@ public class ConversationListBox : Gtk.ListBox {
 
     public async void load_conversation()
         throws Error {
-        EmailRow? first_expanded_row = null;
-
         // Fetch full emails from the conversation
         Gee.Collection<Geary.Email> full_emails =
             yield load_full_emails(
@@ -337,17 +335,17 @@ public class ConversationListBox : Gtk.ListBox {
             );
 
         // Add them all
+        EmailRow? first_expanded_row = null;
         foreach (Geary.Email full_email in full_emails) {
             if (this.cancellable.is_cancelled()) {
                 break;
             }
             if (!this.email_rows.contains(full_email.id)) {
                 EmailRow row = add_email(full_email);
-                if (first_expanded_row == null && row.is_expanded) {
+                if (row.is_expanded &&
+                    (first_expanded_row == null ||
+                     on_sort(row, first_expanded_row) < 0)) {
                     first_expanded_row = row;
-                    yield first_expanded_row.view.start_loading(
-                        this.cancellable
-                    );
                 }
             }
         }
@@ -356,21 +354,15 @@ public class ConversationListBox : Gtk.ListBox {
         EmailRow? last_email = this.last_row as EmailRow;
 
         if (last_email != null && !this.cancellable.is_cancelled()) {
-            // The last row should always be expanded, so expand it
-            // and start loading if needed.
-            last_email.expand();
-            if (last_email != first_expanded_row) {
-                yield last_email.view.start_loading(this.cancellable);
-            }
-
             // If no other row was expanded by default, use the last
-            // row.
             if (first_expanded_row == null) {
+                last_email.expand();
                 first_expanded_row = last_email;
             }
 
-            // Ensure we scroll to the first expanded roll when it
-            // finishes loading
+            // Start the first expanded row loading before any others,
+            // scroll the view to it when its done
+            yield first_expanded_row.view.start_loading(this.cancellable);
             first_expanded_row.should_scroll.connect(scroll_to);
             first_expanded_row.enable_should_scroll();
 


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