(js) Fix handling of attachments in mail editor

Fixes #4058, #4063
This commit is contained in:
Francis Lachapelle
2017-03-03 15:36:52 -05:00
parent 3c35c16bf3
commit 75aa6e90a2
3 changed files with 4 additions and 3 deletions
@@ -157,7 +157,7 @@
*/
Mailbox.prototype.init = function(data) {
var _this = this;
if (data.headers) {
if (angular.isUndefined(this.uidsMap) || data.headers) {
this.$isLoading = true;
this.$messages = [];
this.uidsMap = {};
@@ -474,9 +474,9 @@
* @param {string} filename - the filename of the attachment to delete
*/
Message.prototype.$deleteAttachment = function(filename) {
var action = 'deleteAttachment?filename=' + filename;
var data = { 'filename': filename };
var _this = this;
Message.$$resource.post(this.$absolutePath({asDraft: true}), action).then(function(data) {
Message.$$resource.fetch(this.$absolutePath({asDraft: true}), 'deleteAttachment', data).then(function(data) {
Message.$timeout(function() {
_this.editable.attachmentAttrs = _.filter(_this.editable.attachmentAttrs, function(attachment) {
return attachment.filename != filename;