[geary/mjog/search-update: 46/53] Geary.App.FillWindowOperation: detect stale FillWindowOperations




commit 8d4387ae86bba445727a96f6e5dccc5d8ff56547
Author: Douglas Fuller <douglas fuller gmail com>
Date:   Tue Oct 6 17:50:52 2020 -0400

    Geary.App.FillWindowOperation: detect stale FillWindowOperations
    
    When a user types in the search box, there may still be oustanding
    FillWindowOperations queued on previous instances of SearchFolder
    from previous keystrokes. This can result in a FillWindowOperation
    with a stale value of ConversationMonitor.window_lowest from a previous
    search executing on the current one. Detect this and return immediately.
    
    Fixes: #838

 .../app-fill-window-operation.vala                 | 24 ++++++++++++++++------
 1 file changed, 18 insertions(+), 6 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 9f34797b1..a7ca8b8cb 100644
--- a/src/engine/app/conversation-monitor/app-fill-window-operation.vala
+++ b/src/engine/app/conversation-monitor/app-fill-window-operation.vala
@@ -37,9 +37,16 @@ private class Geary.App.FillWindowOperation : ConversationOperation {
             num_to_load = MAX_FILL_COUNT;
         }
 
-        int loaded = yield this.monitor.load_by_id_async(
-            this.monitor.window_lowest, num_to_load, LOCAL_ONLY
-        );
+        int loaded = 0;
+
+        try {
+            loaded = yield this.monitor.load_by_id_async(
+                this.monitor.window_lowest, num_to_load, LOCAL_ONLY
+            );
+        } catch (EngineError.NOT_FOUND err) {
+            debug("Stale FillWindowOperation: %s", err.message);
+            return;
+        }
 
         debug(
             "Filled %d of %d locally, window: %d, total: %d",
@@ -61,9 +68,14 @@ private class Geary.App.FillWindowOperation : ConversationOperation {
             // 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
-            );
+            try {
+                loaded = yield this.monitor.load_by_id_async(
+                    this.monitor.window_lowest, num_to_load, FORCE_UPDATE
+                );
+            } catch (EngineError.NOT_FOUND err) {
+                debug("Stale FillWindowOperation: %s", err.message);
+                return;
+            }
 
             debug(
                 "Filled %d of %d from the remote, window: %d, total: %d",


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