[geary/mjog/493-undo-send: 5/6] Ensure saved drafts are reused when reusing Composer.Widget



commit ce5d610f50e1913604f16a344a8a7b1577145c90
Author: Michael Gratton <mike vee net>
Date:   Wed Nov 13 08:37:42 2019 +1100

    Ensure saved drafts are reused when reusing Composer.Widget
    
    Convert ::current_draft_id back to an auto property and update its
    value manually. Pass it to the draft-manager when re-opening due to
    re-enabling the composer, so that SaveComposerCommand when undone will
    start updating the previousl used draft.

 src/client/composer/composer-widget.vala | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 4848838c..5fa3bcc4 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -222,10 +222,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
 
     /** The identifier of the draft this composer holds, if any. */
     public Geary.EmailIdentifier? current_draft_id {
-        get {
-            return this.draft_manager != null
-                ? this.draft_manager.current_draft_id : null;
-        }
+        get; private set; default = null;
     }
 
     /** Determines the composer's current presentation mode. */
@@ -861,7 +858,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
 
         if (enabled) {
             this.is_closing = false;
-            this.open_draft_manager.begin(null, null);
+            this.open_draft_manager.begin(this.current_draft_id, null);
         } else {
             if (this.container != null) {
                 this.container.close();
@@ -1600,7 +1597,9 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
 
         // cancel timer in favor of this operation
         this.draft_timer.reset();
+
         yield this.draft_manager.discard(null);
+        this.current_draft_id = null;
     }
 
     private async void save_and_exit() {
@@ -2439,7 +2438,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
     }
 
     private void on_draft_id_changed() {
-        notify_property("current-draft-id");
+        this.current_draft_id = this.draft_manager.current_draft_id;
     }
 
     private void on_draft_manager_fatal(Error err) {


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