[geary/wip/search-fixes: 11/23] Make ConversationMonitor's Fill op use local-only initially



commit ebc3b992bc9e78681a7e95762839b0b54f06f5a1
Author: Michael Gratton <mike vee net>
Date:   Sun Aug 18 18:34:32 2019 +1000

    Make ConversationMonitor's Fill op use local-only initially
    
    Go local first and only hit the remote when out of local messages.

 .../app-fill-window-operation.vala                 | 48 +++++++++++++++++-----
 1 file changed, 37 insertions(+), 11 deletions(-)
---
diff --git a/src/engine/app/conversation-monitor/app-fill-window-operation.vala 
b/src/engine/app/conversation-monitor/app-fill-window-operation.vala
index 40231bc9..bd6595fc 100644
--- a/src/engine/app/conversation-monitor/app-fill-window-operation.vala
+++ b/src/engine/app/conversation-monitor/app-fill-window-operation.vala
@@ -37,22 +37,48 @@ private class Geary.App.FillWindowOperation : ConversationOperation {
             num_to_load = MAX_FILL_COUNT;
         }
 
-        debug(
-            "Filling %d messages in %s...",
-            num_to_load, this.monitor.base_folder.to_string()
+        int loaded = yield this.monitor.load_by_id_async(
+            this.monitor.window_lowest, num_to_load, LOCAL_ONLY
         );
 
-        int loaded = yield this.monitor.load_by_id_async(
-            this.monitor.window_lowest, num_to_load
+        debug(
+            "Filled %d of %d locally, window: %d, total: %d",
+            loaded, num_to_load,
+            this.monitor.conversations.size,
+            this.monitor.base_folder.properties.email_total
         );
 
-        // Check to see if we need any more, but only if there might
-        // be some more to load either locally or from the remote. If
-        // we loaded the full amount, there might be some more
-        // locally, so try that. If not, but the monitor thinks there
-        // are more to load, then we have go check the remote.
-        if (loaded == num_to_load || this.monitor.can_load_more) {
+        if (loaded < num_to_load &&
+            this.monitor.can_load_more &&
+            this.monitor.base_folder.get_open_state() == REMOTE) {
+            // Not enough were loaded locally, but the remote seems to
+            // be online and it looks like there and there might be
+            // some more on the remote, so go see if there are any.
+            //
+            // XXX Ideally this would be performed as an explicit user
+            // action
+
+            // Load the max amount if going to the trouble of talking
+            // to the remote.
+            num_to_load = MAX_FILL_COUNT;
+            loaded = yield this.monitor.load_by_id_async(
+                this.monitor.window_lowest, num_to_load, FORCE_UPDATE
+            );
+
+            debug(
+                "Filled %d of %d from the remote, window: %d, total: %d",
+                loaded, num_to_load,
+                this.monitor.conversations.size,
+                this.monitor.base_folder.properties.email_total
+            );
+
+        }
+
+        if (loaded == num_to_load) {
+            // Loaded the maximum number of messages, so go see if
+            // there are any more needed.
             this.monitor.check_window_count();
         }
+
     }
 }


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