[geary/mjog/fix-null-id-saving-drafts] Fix an assertion failing when saving a draft for the first time



commit 7ddeb8d7a61fce74ff88b5ea0d75e9469af4fc44
Author: Michael Gratton <mike vee net>
Date:   Sat Sep 28 20:56:36 2019 +1000

    Fix an assertion failing when saving a draft for the first time
    
    Introduced by !297

 src/engine/app/app-draft-manager.vala | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/engine/app/app-draft-manager.vala b/src/engine/app/app-draft-manager.vala
index 1ff0fb4a..df41305c 100644
--- a/src/engine/app/app-draft-manager.vala
+++ b/src/engine/app/app-draft-manager.vala
@@ -424,7 +424,8 @@ public class Geary.App.DraftManager : BaseObject {
 
         this.draft_state = DraftState.STORING;
 
-        // if draft supplied, save it
+        // if draft supplied, save it, and delete the old one if it
+        // exists
         if (op.draft != null) {
             try {
                 EmailIdentifier? old_id = this.current_draft_id;
@@ -435,9 +436,12 @@ public class Geary.App.DraftManager : BaseObject {
                         op.date_received,
                         null
                     );
-                yield this.remove_support.remove_email_async(
-                    Collection.single(old_id), null
-                );
+
+                if (old_id != null) {
+                    yield this.remove_support.remove_email_async(
+                        Collection.single(old_id), null
+                    );
+                }
 
                 this.draft_state = DraftState.STORED;
                 notify_stored(op.draft);


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