From d81539af3135428fafe5ea9764755aa1a697cbb4 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 08 Jul 2014 12:22:40 -0400
Subject: [PATCH] Fix bug where compose storage wasn't cleared on page unload (#1489818)

---
 CHANGELOG         |    1 +
 program/js/app.js |    8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index aa22fb0..e76a85f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -57,6 +57,7 @@
 - Fix Delete button state after deleting identity/response (#1489972)
 - Fix bug where contacts with no email address were listed on compose addressbook (#1489970)
 - Fix images import from various vCard formats (#1489977)
+- Fix bug where compose storage wasn't cleared on page unload (#1489818)
 
 RELEASE 1.0.1
 -------------
diff --git a/program/js/app.js b/program/js/app.js
index 31c23dd..c635f60 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -655,9 +655,6 @@
     if (this.task == 'mail' && this.env.action == 'compose' && $.inArray(command, this.env.compose_commands) < 0 && !this.env.server_error) {
       if (this.cmp_hash != this.compose_field_hash() && !confirm(this.get_label('notsentwarning')))
         return false;
-
-      // remove copy from local storage if compose screen is left intentionally
-      this.remove_compose_data(this.env.compose_id);
     }
 
     this.last_command = command;
@@ -3803,6 +3800,11 @@
           ref.compose_type_activity_last = ref.compose_type_activity;
         }
       }, 5000);
+
+      // remove data from local storage if compose screen is left
+      $(window).unload(function() {
+        ref.remove_compose_data(ref.env.compose_id);
+      });
     }
 
     // Unlock interface now that saving is complete

--
Gitblit v1.9.1