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
This commit is contained in:
Douglas Fuller 2020-10-06 17:50:52 -04:00 committed by Michael James Gratton
parent bb02e157c6
commit 90711f234e

View file

@ -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(
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;
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",