[geary] Fix empty folder/no matching search UI not showing up.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Fix empty folder/no matching search UI not showing up.
- Date: Sun, 8 Jul 2018 05:13:02 +0000 (UTC)
commit 4cc7cf1769317074f1c4daae250554d635db2f6d
Author: Michael James Gratton <mike vee net>
Date: Sun Jul 8 15:11:44 2018 +1000
Fix empty folder/no matching search UI not showing up.
This fixes a regression introduced by commit 0ea1fe6c3.
* src/engine/app/app-conversation-monitor.vala (ConversationMonitor):
Signal scan_complete from the same method call that we signal
scan_started, so that a) we know it will get fired, even if no messages
are loaded (the issue introduced by 0ea1fe6c3) and b) so we can get rid
of the inside_scan complexity.
src/engine/app/app-conversation-monitor.vala | 44 +++++++++++++---------
test/engine/app/app-conversation-monitor-test.vala | 13 +++++++
2 files changed, 39 insertions(+), 18 deletions(-)
---
diff --git a/src/engine/app/app-conversation-monitor.vala b/src/engine/app/app-conversation-monitor.vala
index b7541f51..e3d58de4 100644
--- a/src/engine/app/app-conversation-monitor.vala
+++ b/src/engine/app/app-conversation-monitor.vala
@@ -50,15 +50,15 @@ public class Geary.App.ConversationMonitor : BaseObject {
Geary.Email.Field.FLAGS | Geary.Email.Field.DATE;
- private class ProcessJobContext : BaseObject {
- public Gee.HashMap<Geary.EmailIdentifier, Geary.Email> emails
- = new Gee.HashMap<Geary.EmailIdentifier, Geary.Email>();
+ private struct ProcessJobContext {
- public bool inside_scan;
+ public Gee.Map<Geary.EmailIdentifier,Geary.Email> emails;
- public ProcessJobContext(bool inside_scan) {
- this.inside_scan = inside_scan;
+
+ public ProcessJobContext() {
+ this.emails = new Gee.HashMap<Geary.EmailIdentifier,Geary.Email>();
}
+
}
@@ -402,6 +402,7 @@ public class Geary.App.ConversationMonitor : BaseObject {
}
int load_count = 0;
+ GLib.Error? scan_error = null;
try {
Gee.Collection<Geary.Email>? messages =
yield this.base_folder.list_email_by_id_async(
@@ -416,12 +417,16 @@ public class Geary.App.ConversationMonitor : BaseObject {
this.window.add(email.id);
}
- yield process_email_async(messages, new ProcessJobContext(true));
+ yield process_email_async(messages, ProcessJobContext());
}
+ } catch (GLib.Error err) {
+ scan_error = err;
+ }
- } catch (Error err) {
- notify_scan_completed();
- throw err;
+ notify_scan_completed();
+
+ if (scan_error != null) {
+ throw scan_error;
}
return load_count;
@@ -437,6 +442,7 @@ public class Geary.App.ConversationMonitor : BaseObject {
flags |= Folder.ListFlags.LOCAL_ONLY;
}
+ GLib.Error? scan_error = null;
try {
Gee.Collection<Geary.Email>? messages =
yield this.base_folder.list_email_by_sparse_id_async(
@@ -448,11 +454,16 @@ public class Geary.App.ConversationMonitor : BaseObject {
this.window.add(email.id);
}
- yield process_email_async(messages, new ProcessJobContext(true));
+ yield process_email_async(messages, ProcessJobContext());
}
- } catch (Error err) {
- notify_scan_completed();
- throw err;
+ } catch (GLib.Error err) {
+ scan_error = err;
+ }
+
+ notify_scan_completed();
+
+ if (scan_error != null) {
+ throw scan_error;
}
}
@@ -524,7 +535,7 @@ public class Geary.App.ConversationMonitor : BaseObject {
if (emails != null && !emails.is_empty) {
debug("Fetched %d relevant emails locally", emails.size);
- yield process_email_async(emails, new ProcessJobContext(false));
+ yield process_email_async(emails, ProcessJobContext());
}
}
@@ -727,9 +738,6 @@ public class Geary.App.ConversationMonitor : BaseObject {
foreach (Conversation conversation in appended.get_keys())
notify_conversation_appended(conversation, appended.get(conversation));
}
-
- if (job.inside_scan)
- notify_scan_completed();
}
private async void expand_conversations_async(Gee.Set<RFC822.MessageID> needed_message_ids,
diff --git a/test/engine/app/app-conversation-monitor-test.vala
b/test/engine/app/app-conversation-monitor-test.vala
index 4a811e8f..285a62b4 100644
--- a/test/engine/app/app-conversation-monitor-test.vala
+++ b/test/engine/app/app-conversation-monitor-test.vala
@@ -56,6 +56,11 @@ class Geary.App.ConversationMonitorTest : TestCase {
);
Cancellable test_cancellable = new Cancellable();
+ bool saw_scan_started = false;
+ bool saw_scan_completed = false;
+ monitor.scan_started.connect(() => { saw_scan_started = true; });
+ monitor.scan_completed.connect(() => { saw_scan_completed = true; });
+
this.base_folder.expect_call(
"open_async",
{ MockObject.int_arg(Folder.OpenFlags.NONE), test_cancellable }
@@ -68,11 +73,19 @@ class Geary.App.ConversationMonitorTest : TestCase {
);
monitor.start_monitoring_async.end(async_result());
+ // Process all of the async tasks arising from the open
+ while (this.main_loop.pending()) {
+ this.main_loop.iteration(true);
+ }
+
monitor.stop_monitoring_async.begin(
test_cancellable, (obj, res) => { async_complete(res); }
);
monitor.stop_monitoring_async.end(async_result());
+ assert_true(saw_scan_started, "scan_started not fired");
+ assert_true(saw_scan_completed, "scan_completed not fired");
+
this.base_folder.assert_expectations();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]