[geary/wip/conversation-polish: 3/22] Fix ConversationEmail.email having no flags after message load
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/conversation-polish: 3/22] Fix ConversationEmail.email having no flags after message load
- Date: Tue, 29 Jan 2019 05:38:43 +0000 (UTC)
commit b23ff03191c80ff258406c2f03a1ab14c6abc989
Author: Michael Gratton <mike vee net>
Date: Wed Jan 23 16:06:24 2019 +1100
Fix ConversationEmail.email having no flags after message load
This broke auto-mark-read, since when testing if the message was unread,
it was always uncertain.
.../conversation-viewer/conversation-email.vala | 30 ++++++++++++----------
.../conversation-viewer/conversation-list-box.vala | 12 ++++-----
2 files changed, 22 insertions(+), 20 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-email.vala
b/src/client/conversation-viewer/conversation-email.vala
index 5c0946ce..41df0869 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -30,6 +30,10 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
/** Fields that must be available for loading the body. */
internal const Geary.Email.Field REQUIRED_FOR_LOAD = (
+ // Include those needed by the constructor since we'll replace
+ // the ctor's email arg value once the body has been fully
+ // loaded
+ REQUIRED_FOR_CONSTRUCT |
Geary.Email.REQUIRED_FOR_MESSAGE
);
@@ -558,17 +562,16 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
// Ensure we have required data to load the message
- Geary.Email? email = null;
- if (this.email.fields.fulfills(REQUIRED_FOR_LOAD)) {
- email = this.email;
- } else {
+ bool loaded = this.email.fields.fulfills(REQUIRED_FOR_LOAD);
+ if (!loaded) {
try {
- email = yield this.email_store.fetch_email_async(
+ this.email = yield this.email_store.fetch_email_async(
this.email.id,
- Geary.Email.REQUIRED_FOR_MESSAGE,
- LOCAL_ONLY, // Throw an error if not downloaded
+ REQUIRED_FOR_LOAD,
+ LOCAL_ONLY, // Throws an error if not downloaded
this.load_cancellable
);
+ loaded = true;
} catch (Geary.EngineError.INCOMPLETE_MESSAGE err) {
// Don't have the complete message at the moment, so
// download it in the background.
@@ -576,8 +579,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
}
}
- if (email != null) {
- this.email = email;
+ if (loaded) {
yield update_body();
yield this.message_bodies_loaded_lock.wait_async(
this.load_cancellable
@@ -717,11 +719,11 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
// XXX Need proper progress reporting here, rather than just
// doing a pulse
this.primary_message.start_progress_pulse();
- Geary.Email? email = null;
+ Geary.Email? loaded = null;
try {
- email = yield this.email_store.fetch_email_async(
+ loaded = yield this.email_store.fetch_email_async(
this.email.id,
- Geary.Email.REQUIRED_FOR_MESSAGE,
+ REQUIRED_FOR_LOAD,
FORCE_UPDATE,
this.load_cancellable
);
@@ -735,10 +737,10 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
this.primary_message.stop_progress_pulse();
}
- if (email != null) {
+ if (loaded != null) {
this.primary_message.stop_progress_pulse();
try {
- this.email = email;
+ this.email = loaded;
yield update_body();
} catch (GLib.Error err) {
debug("Remote message update failed: %s", err.message);
diff --git a/src/client/conversation-viewer/conversation-list-box.vala
b/src/client/conversation-viewer/conversation-list-box.vala
index f945f83c..47f81ae0 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -727,14 +727,14 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
// Loads full version of an email, adds it to the listbox
private async void load_full_email(Geary.EmailIdentifier id)
- throws Error {
+ throws GLib.Error {
+ // Even though it would save a around-trip, don't load the
+ // full email here so that ConverationEmail can handle it if
+ // the full email isn't actually available in the same way as
+ // any other.
Geary.Email full_email = yield this.email_store.fetch_email_async(
id,
- (
- REQUIRED_FIELDS |
- ConversationEmail.REQUIRED_FOR_CONSTRUCT |
- ConversationEmail.REQUIRED_FOR_LOAD
- ),
+ REQUIRED_FIELDS | ConversationEmail.REQUIRED_FOR_CONSTRUCT,
Geary.Folder.ListFlags.NONE,
this.cancellable
);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]