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



commit b01d40b391a252dc4fa7fa4c117ab122e911097c
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 8898844d..ebb137d0 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. */
@@ -862,7 +859,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();
@@ -1601,7 +1598,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_close() {
@@ -2440,7 +2439,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]