summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2013-11-10 18:50:17 +0100
committerThomas Bruederli <thomas@roundcube.net>2013-11-10 18:50:17 +0100
commitceb2a31b3857925e749047e2c4c574a38bf8e9ed (patch)
treed8edab893f1cf11d687020ed4e12f4cc59e375af
parent7bfc02e122a6f043be5b03bc91ecb4d87e9afc15 (diff)
Compare draft message-ID when restoring local message contents
-rw-r--r--program/js/app.js15
-rw-r--r--program/steps/mail/compose.inc3
2 files changed, 16 insertions, 2 deletions
diff --git a/program/js/app.js b/program/js/app.js
index 4090cbe4c..257c10980 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3131,13 +3131,20 @@ function rcube_webmail()
for (var key, i = 0; i < index.length; i++) {
key = index[i], formdata = this.local_storage_get_item('compose.' + key, null, true);
+ if (!formdata) {
+ continue;
+ }
// restore saved copy of current compose_id
- if (formdata && formdata.changed && key == this.env.compose_id) {
+ if (formdata.changed && key == this.env.compose_id) {
this.restore_compose_form(key, html_mode);
break;
}
+ // skip records from 'other' drafts
+ if (this.env.draft_id && formdata.draft_id && formdata.draft_id != this.env.draft_id) {
+ continue;
+ }
// show dialog asking to restore the message
- if (formdata && formdata.changed && formdata.session != this.env.session_id) {
+ if (formdata.changed && formdata.session != this.env.session_id) {
this.show_popup_dialog(
this.get_label('restoresavedcomposedata')
.replace('$date', new Date(formdata.changed).toLocaleString())
@@ -3671,6 +3678,10 @@ function rcube_webmail()
tinyMCE.triggerSave();
}
+ if (this.env.draft_id) {
+ formdata.draft_id = this.env.draft_id;
+ }
+
$('input, select, textarea', this.gui_objects.messageform).each(function(i, elem){
switch (elem.tagName.toLowerCase()) {
case 'input':
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index a791cf8b7..8d275f930 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -240,6 +240,9 @@ if (!empty($msg_uid) && empty($COMPOSE['as_attachment']))
$COMPOSE['reply_msgid'] = '<' . $in_reply_to . '>';
$COMPOSE['references'] = $MESSAGE->headers->references;
+
+ // use message-ID as draft_id, same as in sendmail.inc
+ $OUTPUT->set_env('draft_id', trim($MESSAGE->headers->get('message-id'), '<>'));
}
}
else {