[geary/wip/conversation-polish: 5/22] Replace pair of ConversationEmail body load state bools with single enum
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/conversation-polish: 5/22] Replace pair of ConversationEmail body load state bools with single enum
- Date: Tue, 29 Jan 2019 05:38:53 +0000 (UTC)
commit 43080b891180f68ffbb1a679f5de88fe286a1ad0
Author: Michael Gratton <mike vee net>
Date: Wed Jan 23 16:27:36 2019 +1100
Replace pair of ConversationEmail body load state bools with single enum
Reduces complexity a bit, provides a single property to track load state
changes.
.../conversation-viewer/conversation-email.vala | 26 +++++++++++++++-------
.../conversation-viewer/conversation-list-box.vala | 8 +++----
2 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-email.vala
b/src/client/conversation-viewer/conversation-email.vala
index 1593c19c..297c382f 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -41,6 +41,19 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
private const int BODY_LOAD_TIMEOUT_MSEC = 250;
+ /** Specifies the loading state for a message part. */
+ public enum LoadState {
+
+ /** Loading has not started. */
+ NOT_STARTED,
+
+ /** Loading has started, but not completed. */
+ STARTED,
+
+ /** Loading has started and completed. */
+ COMPLETED;
+ }
+
/**
* Iterator that returns all message views in an email view.
*/
@@ -282,11 +295,8 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
private Gee.List<ConversationMessage> _attached_messages =
new Gee.LinkedList<ConversationMessage>();
- /** Determines if message bodies have started loading. */
- public bool message_body_load_started { get; private set; default = false; }
-
- /** Determines if all message have had loaded their bodies. */
- public bool message_bodies_loaded { get; private set; default = false; }
+ /** Determines the message body loading state. */
+ public LoadState message_body_state { get; private set; default = NOT_STARTED; }
// Store from which to load message content, if needed
private Geary.App.EmailStore email_store;
@@ -568,7 +578,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
*/
public async void load_body()
throws GLib.Error {
- this.message_body_load_started = true;
+ this.message_body_state = STARTED;
// Ensure we have required data to load the message
@@ -993,8 +1003,8 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
break;
}
}
- if (all_loaded && !this.message_bodies_loaded) {
- this.message_bodies_loaded = true;
+ if (all_loaded && this.message_body_state != COMPLETED) {
+ this.message_body_state = COMPLETED;
this.message_bodies_loaded_lock.blind_notify();
// Update attachments once the web views have finished
diff --git a/src/client/conversation-viewer/conversation-list-box.vala
b/src/client/conversation-viewer/conversation-list-box.vala
index 47f81ae0..e1f29e56 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -147,7 +147,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
throws GLib.Error {
this.is_expanded = true;
update_row_expansion();
- if (!this.view.message_body_load_started) {
+ if (this.view.message_body_state == NOT_STARTED) {
yield this.view.load_body();
}
foreach (ConversationMessage message in this.view) {
@@ -840,7 +840,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
// size of the body will be off, affecting the visibility
// of emails further down the conversation.
if (email_view.email.is_unread().is_certain() &&
- email_view.message_bodies_loaded &&
+ email_view.message_body_state == COMPLETED &&
!email_view.is_manually_read) {
int body_top = 0;
int body_left = 0;
@@ -881,10 +881,10 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
}
private void apply_search_terms(EmailRow row) {
- if (row.view.message_bodies_loaded) {
+ if (row.view.message_body_state == COMPLETED) {
this.apply_search_terms_impl.begin(row);
} else {
- row.view.notify["message-bodies-loaded"].connect(() => {
+ row.view.notify["message-body-state"].connect(() => {
this.apply_search_terms_impl.begin(row);
});
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]