(fix) moved the mailbox cleanup after expunge in the service

This commit is contained in:
Ludovic Marcotte
2015-08-11 14:48:45 -04:00
parent 2e3057c2ce
commit 9362513fee
2 changed files with 17 additions and 5 deletions
@@ -413,7 +413,22 @@
* @returns a promise of the HTTP operation
*/
Mailbox.prototype.$emptyTrash = function() {
return Mailbox.$$resource.post(this.id, 'emptyTrash');
var _this = this,
deferred = Mailbox.$q.defer(),
promise;
promise = Mailbox.$$resource.post(this.id, 'emptyTrash');
promise.then(function() {
// Remove all messages from the mailbox
_this.$messages = [];
_this.uidsMap = {};
_this.unseenCount = 0;
}, function(data, status) {
deferred.reject(data);
});
return deferred.promise;
};
/**
@@ -138,10 +138,7 @@
function emptyTrashFolder(folder) {
folder.$emptyTrash().then(function() {
// Success - remove all messages from the mailbox
folder.$messages = [];
folder.uidsMap = {};
folder.unseenCount = 0;
// Success
}, function(error) {
Dialog.alert(l('Warning'), error);
});