[geary/wip/draft-management: 23/27] Infer draft status from composer's draft_id property



commit b4f4cbbe081e01c6e204c44851c98da8ce8b580f
Author: Michael Gratton <mike vee net>
Date:   Fri Aug 2 11:14:28 2019 +1000

    Infer draft status from composer's draft_id property
    
    This lets remove the `is_draft` flag from a bunch of places, simplifying
    logic at a number of call sites.

 src/client/application/application-controller.vala      | 7 ++-----
 src/client/components/main-window.vala                  | 2 +-
 src/client/composer/composer-widget.vala                | 8 ++++++--
 src/client/conversation-viewer/conversation-viewer.vala | 8 +++++---
 4 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/src/client/application/application-controller.vala 
b/src/client/application/application-controller.vala
index 9bd3f44a..0ff2b9ed 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -2090,8 +2090,7 @@ public class Application.Controller : Geary.BaseObject {
         if (widget.state == INLINE || widget.state == INLINE_COMPACT) {
             this.main_window.conversation_viewer.do_compose_embedded(
                 widget,
-                referred,
-                is_draft
+                referred
             );
         } else {
             this.main_window.show_composer(widget);
@@ -2102,7 +2101,6 @@ public class Application.Controller : Geary.BaseObject {
             widget,
             referred,
             quote,
-            is_draft,
             this.cancellable_folder
         );
     }
@@ -2111,7 +2109,6 @@ public class Application.Controller : Geary.BaseObject {
                                      ComposerWidget widget,
                                      Geary.Email? referred = null,
                                      string? quote = null,
-                                     bool is_draft = false,
                                      GLib.Cancellable? cancellable) {
         Geary.Email? full = null;
         if (referred != null) {
@@ -2129,7 +2126,7 @@ public class Application.Controller : Geary.BaseObject {
                 }
             }
         }
-        yield widget.load(full, quote, is_draft, cancellable);
+        yield widget.load(full, quote, cancellable);
         widget.set_focus();
     }
 
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index a634679f..6d07b5a7 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -225,7 +225,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
         composer.to = to.to_full_display();
         controller.add_composer(composer);
         show_composer(composer);
-        composer.load.begin(null, null, false, null);
+        composer.load.begin(null, null, null);
     }
 
     /** Displays a composer in the window if possible, else in a new window. */
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 48ddbcba..fbcb6689 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -633,10 +633,14 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
      */
     public async void load(Geary.Email? referred = null,
                            string? quote = null,
-                           bool is_referred_draft = false,
                            GLib.Cancellable? cancellable) {
-        this.last_quote = quote;
+        bool is_referred_draft = (
+            referred != null &&
+            this.draft_id != null &&
+            referred.id.equal_to(this.draft_id)
+        );
         string referred_quote = "";
+        this.last_quote = quote;
         if (referred != null) {
             referred_quote = fill_in_from_referred(referred, quote);
             if (is_referred_draft ||
diff --git a/src/client/conversation-viewer/conversation-viewer.vala 
b/src/client/conversation-viewer/conversation-viewer.vala
index cce1b14d..dd3efb89 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -162,8 +162,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
      * Puts the view into composer mode, showing an embedded composer.
      */
     public void do_compose_embedded(ComposerWidget composer,
-                                    Geary.Email? referred,
-                                    bool is_draft) {
+                                    Geary.Email? referred) {
         this.current_composer = composer;
         ComposerEmbed embed = new ComposerEmbed(
             referred,
@@ -178,7 +177,10 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
         conversation_scroller.kinetic_scrolling = false;
 
         if (this.current_list != null) {
-            this.current_list.add_embedded_composer(embed, is_draft);
+            this.current_list.add_embedded_composer(
+                embed,
+                composer.draft_id != null
+            );
         }
 
         conversation_scroller.kinetic_scrolling = true;


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