summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovane <giovaneliberato@gmail.com>2015-11-27 21:12:19 -0200
committerGiovane <giovaneliberato@gmail.com>2015-11-27 21:12:58 -0200
commit935b1b6f1f200a995dc1f82391a26dfe59a87e50 (patch)
treedcd751443b0966e6b5dcda2f9accf3eacb44171a
parent230ac791547576850e886e1d927b400dbe65e505 (diff)
Permanently delete discarded drafts #512 w/ bwagner
-rw-r--r--service/pixelated/adapter/services/mail_service.py2
-rw-r--r--web-ui/app/js/mixins/with_mail_edit_base.js16
-rw-r--r--web-ui/test/spec/mixins/with_mail_edit_base.spec.js13
3 files changed, 12 insertions, 19 deletions
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py
index 6ecf3245..f0bc056b 100644
--- a/service/pixelated/adapter/services/mail_service.py
+++ b/service/pixelated/adapter/services/mail_service.py
@@ -122,7 +122,7 @@ class MailService(object):
def delete_mail(self, mail_id):
mail = yield self.mail(mail_id)
if mail is not None:
- if mail.mailbox_name.upper() == u'TRASH':
+ if mail.mailbox_name.upper() in (u'TRASH', u'DRAFTS'):
yield self.mail_store.delete_mail(mail_id)
else:
yield self.mail_store.move_mail_to_mailbox(mail_id, 'TRASH')
diff --git a/web-ui/app/js/mixins/with_mail_edit_base.js b/web-ui/app/js/mixins/with_mail_edit_base.js
index a3c88e66..36d5980f 100644
--- a/web-ui/app/js/mixins/with_mail_edit_base.js
+++ b/web-ui/app/js/mixins/with_mail_edit_base.js
@@ -91,7 +91,7 @@ define(
this.attr.recipientValues = context.recipients;
this.attachRecipients(context);
- this.on(this.select('trashButton'), 'click', this.trashMail);
+ this.on(this.select('trashButton'), 'click', this.discardMail);
SendButton.attachTo(this.select('sendButton'));
this.warnSendButtonOfRecipients();
@@ -103,12 +103,6 @@ define(
DraftSaveStatus.attachTo(this.select('draftSaveStatus'));
};
- this.deleteMail = function(data) {
- this.attr.ident = data.ident;
- var mail = this.buildMail();
- this.trigger(document, events.ui.mail.delete, { mail: mail });
- };
-
this.monitorInput = function() {
this.trigger(events.ui.mail.changedSinceLastSave);
this.cancelPostponedSaveDraft();
@@ -116,13 +110,11 @@ define(
this.postponeSaveDraft(mail);
};
- this.trashMail = function() {
+ this.discardMail = function() {
this.cancelPostponedSaveDraft();
if (this.attr.ident) {
- this.trigger(document, events.mail.save, {
- mail: this.buildMail(),
- callback: this.deleteMail.bind(this)
- });
+ var mail = this.buildMail();
+ this.trigger(document, events.ui.mail.delete, { mail: mail });
} else {
this.trigger(document, events.ui.mail.discard);
}
diff --git a/web-ui/test/spec/mixins/with_mail_edit_base.spec.js b/web-ui/test/spec/mixins/with_mail_edit_base.spec.js
index 2ad12361..f9e5600a 100644
--- a/web-ui/test/spec/mixins/with_mail_edit_base.spec.js
+++ b/web-ui/test/spec/mixins/with_mail_edit_base.spec.js
@@ -69,25 +69,26 @@ describeMixin('mixins/with_mail_edit_base', function () {
});
describe('when user asks to discard the mail', function() {
- var mailSaveSpy, mailDiscardSpy;
+ var mailDeleteSpy, mailDiscardSpy;
beforeEach(function () {
- mailSaveSpy = spyOnEvent(document, Pixelated.events.mail.save);
+ mailDeleteSpy = spyOnEvent(document, Pixelated.events.ui.mail.delete);
mailDiscardSpy = spyOnEvent(document, Pixelated.events.ui.mail.discard);
});
it('discards the mail if it was never saved', function() {
delete this.component.attr.ident;
- this.component.trashMail();
- expect(mailSaveSpy).not.toHaveBeenTriggeredOn(document);
+ this.component.discardMail();
+ expect(mailDeleteSpy).not.toHaveBeenTriggeredOn(document);
expect(mailDiscardSpy).toHaveBeenTriggeredOn(document);
});
it('deletes the draft if it was saved before', function() {
var spy = spyOnEvent(document, Pixelated.events.mail.save);
this.component.attr.ident = 'ident';
- this.component.trashMail();
- expect(mailSaveSpy).toHaveBeenTriggeredOn(document);
+ this.component.discardMail();
+ expect(mailDeleteSpy).toHaveBeenTriggeredOn(document);
+ expect(mailDiscardSpy).not.toHaveBeenTriggeredOn(document);
});
});