[geary/wip/765516-gtk-widget-conversation-viewer: 123/207] Make conversation viewer email flag handling a bit more null-safe.



commit 579589f9445749cf9f4900193a2268889cf7e11c
Author: Michael James Gratton <mike vee net>
Date:   Thu Jul 28 00:47:01 2016 +1000

    Make conversation viewer email flag handling a bit more null-safe.

 .../conversation-viewer/conversation-email.vala    |   10 +++++-----
 .../conversation-viewer/conversation-listbox.vala  |    6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-email.vala 
b/src/client/conversation-viewer/conversation-email.vala
index b3fe8ac..03388f5 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -495,10 +495,10 @@ public class ConversationEmail : Gtk.Box {
     }
 
     private void update_email_state() {
-        Geary.EmailFlags flags = email.email_flags;
+        Geary.EmailFlags? flags = this.email.email_flags;
         Gtk.StyleContext style = get_style_context();
 
-        bool is_unread = !flags.is_unread();
+        bool is_unread = (flags != null && flags.is_unread());
         set_action_enabled(ACTION_MARK_READ, is_unread);
         set_action_enabled(ACTION_MARK_UNREAD, !is_unread);
         set_action_enabled(ACTION_MARK_UNREAD_DOWN, !is_unread);
@@ -508,7 +508,7 @@ public class ConversationEmail : Gtk.Box {
             style.remove_class("geary_unread");
         }
 
-        bool is_flagged = flags.is_flagged();
+        bool is_flagged = (flags != null && flags.is_flagged());
         set_action_enabled(ACTION_STAR, !this.is_collapsed && !is_flagged);
         set_action_enabled(ACTION_UNSTAR, !this.is_collapsed && is_flagged);
         if (is_flagged) {
@@ -521,8 +521,8 @@ public class ConversationEmail : Gtk.Box {
             unstar_button.hide();
         }
 
-        if (flags.is_outbox_sent()) {
-            not_saved_infobar.show();
+        if (flags != null && flags.is_outbox_sent()) {
+            this.not_saved_infobar.show();
         }
     }
 
diff --git a/src/client/conversation-viewer/conversation-listbox.vala 
b/src/client/conversation-viewer/conversation-listbox.vala
index bf38803..ff01094 100644
--- a/src/client/conversation-viewer/conversation-listbox.vala
+++ b/src/client/conversation-viewer/conversation-listbox.vala
@@ -305,7 +305,7 @@ public class ConversationListBox : Gtk.ListBox {
             // Don't bother with not-yet-loaded emails since the
             // size of the body will be off, affecting the visibility
             // of emails further down the conversation.
-            if (email_view.email.email_flags.is_unread() &&
+            if (email_view.email.is_unread().is_certain() &&
                 conversation_message.is_loading_complete &&
                 !email_view.is_manually_read) {
                  int body_top = 0;
@@ -537,8 +537,8 @@ public class ConversationListBox : Gtk.ListBox {
         update_last_row();
         email_added(view);
 
-        if (email.is_unread() == Geary.Trillian.TRUE ||
-            email.is_flagged() == Geary.Trillian.TRUE) {
+        if (email.is_unread().is_certain() ||
+            email.is_flagged().is_certain()) {
             row.expand(false);
         }
         yield view.start_loading(this.cancellable);


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